{"id":1858,"url":"https://github.com/cezheng/PySwiftyRegex","last_synced_at":"2025-08-02T05:32:56.612Z","repository":{"id":34154982,"uuid":"37994412","full_name":"cezheng/PySwiftyRegex","owner":"cezheng","description":"Easily deal with Regex in Swift in a Pythonic way","archived":false,"fork":false,"pushed_at":"2019-08-26T02:52:12.000Z","size":88,"stargazers_count":230,"open_issues_count":3,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-25T19:45:14.777Z","etag":null,"topics":["carthage","cocopods","python","regex","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cezheng.png","metadata":{"files":{"readme":"README-ja.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-24T15:49:15.000Z","updated_at":"2024-01-13T23:53:59.000Z","dependencies_parsed_at":"2022-09-02T14:01:40.866Z","dependency_job_id":null,"html_url":"https://github.com/cezheng/PySwiftyRegex","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cezheng%2FPySwiftyRegex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cezheng%2FPySwiftyRegex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cezheng%2FPySwiftyRegex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cezheng%2FPySwiftyRegex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cezheng","download_url":"https://codeload.github.com/cezheng/PySwiftyRegex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228443642,"owners_count":17920764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","cocopods","python","regex","swift"],"created_at":"2024-01-05T20:15:57.452Z","updated_at":"2024-12-06T09:30:27.975Z","avatar_url":"https://github.com/cezheng.png","language":"Swift","funding_links":[],"categories":["Regex","Libs","Text [🔝](#readme)"],"sub_categories":["React-Like","Text","Other free courses"],"readme":"# PySwiftyRegex\n[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/PySwiftyRegex.svg)](https://cocoapods.org/pods/PySwiftyRegex)\n[![License](https://img.shields.io/cocoapods/l/PySwiftyRegex.svg?style=flat\u0026color=gray)](http://opensource.org/licenses/MIT)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platform](https://img.shields.io/cocoapods/p/PySwiftyRegex.svg?style=flat)](http://cocoadocs.org/docsets/PySwiftyRegex)\n[![Twitter](https://img.shields.io/badge/twitter-@AdamoCheng-blue.svg?style=flat)](http://twitter.com/AdamoCheng)\n\nPythonのようなスッキリした正規表現ライブラリー。\n\n[English](README.md)\n[简体中文](README-zh.md)\n[한국어](README-ko.md)\n\n## コードをみましょう\n\n```swift\nimport PySwiftyRegex\n\nif let m = re.search(\"[Tt]his is (.*?)easy\", \"I think this is really easy!!!\") {\n\tm.group()  // \"this is really easy\"\n\tm.group(1) // \"really \"\n}\n```\nよく使われるメッソドの用例は[こちら](#more_usage)。\n\n## 環境\n\n- iOS 7.0+ / Mac OS X 10.9+\n- Xcode 8.0+\n\n\u003e Swift 2.3はバージョン[0.3.0](../../releases/tag/0.3.0)をご利用ください。\n\n## インストール\n\u003e **Embedded frameworks を使うには iOS 8 または OS X Mavericks 以上は必要です**\n\u003e\n\u003e Deployment Target は iOS 7 のプロジェクトで `PySwiftyRegex` を使うには, [PySwiftyRegex.swift](PySwiftyRegex/PySwiftyRegex.swift) のソースファイルをダウンロードして、Xcodeプロジェクトに追加するのは必要となります。\n\n### CocoaPods(iOS 8+, OS X 10.9+)\n[Cocoapods](http://cocoapods.org/) で簡単に `PySwiftyRegex` をインストールできます。 下記のように`Podfile`を編集してください:\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\n\ntarget 'MyApp' do\n\tpod 'PySwiftyRegex', '~\u003e 1.0.0'\nend\n```\n\nそして、下記のコマンドを実行してください:\n\n```bash\n$ pod install\n```\n\n### Carthage(iOS 8+, OS X 10.9+)\n下記の行を `Cartfile` か `Cartfile.private` かに追加してください:\n\n```\ngithub \"cezheng/PySwiftyRegex\" ~\u003e 1.0.0\n```\nそして、下記のコマンドを実行してください:\n\n```\n$ carthage update\n```\n最後に、ビルドターゲットの`General` -\u003e `Embedded Binaries`に、Carthageがビルドした`PySwiftyRegex.framework`を追加してください。\n\n## 対応したreメソッド\n[**re**](https://docs.python.org/2/library/re.html) モデルを使ったことがあれば, すぐこのライブラリーをご利用できると思います。もしなかったら、下記のPythonドキュメントのリンクをご覧いただけると、このシンプルなモデルに一目惚れするかもしれませんw\n### [re](https://docs.python.org/2/library/re.html#module-contents)\n* [re.compile](https://docs.python.org/2/library/re.html#re.compile)\n* [re.search](https://docs.python.org/2/library/re.html#re.search)\n* [re.match](https://docs.python.org/2/library/re.html#re.match)\n* [re.split](https://docs.python.org/2/library/re.html#re.split)\n* [re.findall](https://docs.python.org/2/library/re.html#re.findall)\n* [re.finditer](https://docs.python.org/2/library/re.html#re.finditer)\n* [re.sub](https://docs.python.org/2/library/re.html#re.sub)\n* [re.subn](https://docs.python.org/2/library/re.html#re.subn)\n\n### [re.RegexObject](https://docs.python.org/2/library/re.html#regular-expression-objects)\n* [search](https://docs.python.org/2/library/re.html#re.RegexObject.search)\n* [match](https://docs.python.org/2/library/re.html#re.RegexObject.match)\n* [split](https://docs.python.org/2/library/re.html#re.RegexObject.split)\n* [findall](https://docs.python.org/2/library/re.html#re.RegexObject.findall)\n* [finditer](https://docs.python.org/2/library/re.html#re.RegexObject.finditer)\n* [sub](https://docs.python.org/2/library/re.html#re.RegexObject.sub)\n* [subn](https://docs.python.org/2/library/re.html#re.RegexObject.subn)\n\n### [re.MatchObject](https://docs.python.org/2/library/re.html#match-objects)\n* [expand](https://docs.python.org/2/library/re.html#re.MatchObject.expand)\n* [group](https://docs.python.org/2/library/re.html#re.MatchObject.group)\n* [groups](https://docs.python.org/2/library/re.html#re.MatchObject.groups)\n* [span](https://docs.python.org/2/library/re.html#re.MatchObject.span)\n\n## \u003ca name=\"more_usage\"\u003e\u003c/a\u003eよく使われるメッソドの用例\n### RegexObjectをコンパイルする\n```swift\nlet regex = re.compile(\"this(.+)that\")\n```\n### 文字列の始めからマッチングする\n```swift\nif let m = regex.match(\"this one is different from that\") {\n\tm.group()  //\"this one is different from that\"\n\tm.group(1) //\" one is different from \"\n}\n```\n### 文字列の中にパターンを探す (first match)\n```swift\nif let m = regex.search(\"I want this one, not that one\") {\n\tm.group()  //\"this one, not that one\"\n\tm.group(1) //\" one, not \"\n}\n```\n### マッチングできた全ての文字列を取得する\n```swift\nregex.findall(\"this or that, this and that\") // [\"this or that\", \"this and that\"]\n```\n### マッチングできた全てのMatchObjectを取得する\n```swift\nfor m in regex.finditer(\"this or that, this and that\") {\n\tm.group()  // 1st time: \"this or that\", second time: \"this and that\"\n\tm.group(1) // 1st time: \" or \", second time: \" and \"\n}\n```\n### パターンで文字列を分割する\n```swift\nlet regex = re.compile(\"[\\\\+\\\\-\\\\*/]\")\n\n// デフォルト、全て分割する\nregex.split(\"1+2-3*4/5\")    // [\"1\", \"2\", \"3\", \"4\", \"5\"]\n\n// 最大分割回数 = 2\nregex.split(\"1+2-3*4/5\", 2) // [\"1\", \"2\", \"3*4/5\"]\n```\n### パターンで文字列を置換する\n```swift\nlet regex = re.compile(\"[Yy]ou\")\n\n// 全て置換する (この例は2回)\nregex.sub(\"u\", \"You guys go grap your food\")     // \"u guys go grap ur food\"\nregex.subn(\"u\", \"You guys go grap your food\")    // (\"u guys go grap ur food\", 2)\n\n// 最大置換回数を1回にする (この例は1回)\nregex.sub(\"u\", \"You guys go grap your food\", 1)  // \"u guys go grap your food\"\nregex.subn(\"u\", \"You guys go grap your food\", 1) // (\"u guys go grap your food\", 1)\n```\n\n## ライセンス\n\n`PySwiftyRegex` のオープンソースライセンスは MIT です。 詳しくはこちら [LICENSE](LICENSE) 。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcezheng%2FPySwiftyRegex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcezheng%2FPySwiftyRegex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcezheng%2FPySwiftyRegex/lists"}