re
了解
🏵 简介
re,一个小巧的Pythonic正则表达式库。
了解更多关于Python 2.x中的re模块的信息。
📋 要求
-
iOS 8.0+
-
macOS 10.9+
-
tvOS 9.0+
-
watchOS 2.0+
-
Xcode 9.0+与Swift 4.1+
📲 安装
re
可作为CocoaPods项目使用。
use_frameworks!
pod 're'
❤️ 贡献
欢迎您fork并提交pull请求。
🔖 许可协议
re
是开源软件,许可协议为MIT
。
🔫 用法
import re
let string: String = ...
let pattern: String = ...
// Swiftly
let regex = RegularExpression.of(pattern)
let matches = regex.matches(in: string)
let groups1 = regex.groups(matches: string)
let groups2 = regex.groups(matches: string, at: 1)
let groups3 = regex.groups(matches: string, at: [1, 2])
let split = regex.split(string)
let replace = regex.replace(with: "BEING_REPLACED", in: string)
// Pythonic
let _ = re.compile(pattern, flags: [])
let _ = re.search(pattern, string)
let _ = re.match(pattern, string)
let _ = re.split(pattern, string)
let _ = re.sub(pattern, string)
// ...