PySwiftyRegex - 以 Pythonic 的方式在 Swift 中轻松处理正则表达式
PySwiftyRegex
以 Pythonic 的方式在 Swift 中轻松处理正则表达式。
这很容易
查看更多示例。
要求
- iOS 7.0+ / Mac OS X 10.9+
- Xcode 8.0+
< 对于 Swift 2.3,请使用版本 0.3.0。
安装
嵌入式框架要求最低部署目标为 iOS 8 或 OS X Mavericks。
要与面向 iOS 7 的项目一起使用,请考虑使用 CocoaSeeds 或将 PySwiftyRegex.swift 文件复制到项目中。
PySwiftyRegex
CocoaPods(iOS 8+, OS X 10.9+)
You can use Cocoapods to install by adding it to your to your :PySwiftyRegex
Podfile
Then, run the following command:
Carthage(iOS 8+, OS X 10.9+)
Adding the following line to your or :Cartfile
Cartfile.private
github "cezheng/PySwiftyRegex" ~> 1.0.0
Run the following command:
$ carthage update
Then drag the built by Carthage into your target's -> .PySwiftyRegex.framework
General
Embedded Binaries
CocoaSeeds (for iOS 7)
CocoaSeeds allows you to use Swift libraries in iOS 7 projects.
Create Seedfile:
Then run the following command:
Now you can see the PySwiftyRegex.swift file in your Xcode project. Build and enjoy!
Supported re methods
If you are familiar with Python's re module, you are ready to go. If not, you may like to check how Python's re is better than the cumbersome NSRegularExpression's APIs, by clicking at the items below.
re
re.RegexObject
re.MatchObject
More Usage Examples
Compile a RegexObject for future reuse
Matching a pattern from beginning
Searching a pattern (first match)
Find all occurrences of a pattern
Get match results for all occurrences of a pattern
Splitting a string with pattern
Replacing a pattern
License
PySwiftyRegex
is released under the MIT license. See LICENSE for details.