Swift 2.0 和Python一樣方便的正則表達式PySwiftyRegex
PySwiftyRegex讓你用Swift也可以像Python一樣簡潔高效地作正則處理。Python的re模塊常用的方法都有實現,包括split, search, find_all, sub等。徹底拋棄NSRegularExpression那套冗長的API吧。
項目地址: https://github.com/cezheng/PySwiftyRegex
簡單的例子
import PySwiftyRegexif let m = re.search("[Tt]his is (.*?)easy", "I think this is really easy!!!") { m.group() // "this is really easy" m.group(1) // "really " }</pre>
詳細請見github的中文README: https://github.com/cezheng/PySwiftyRegex/blob/master/README-zh.md
可以通過CocoaPods,Carthage等包管理器安裝。
CocoaPodspod 'PySwiftyRegex', '~> 0.1.0'
Carthage
github "cezheng/PySwiftyRegex" ~> 0.1.0
</strong>
本文由用戶 cezheng 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!