{"id":32149390,"url":"https://github.com/perfectsiderepos/perfect-regex","last_synced_at":"2025-10-21T09:56:14.172Z","repository":{"id":63920295,"uuid":"82823711","full_name":"PerfectSideRepos/Perfect-RegEx","owner":"PerfectSideRepos","description":"A simple / light weight / independent regular expression extesion for Swift String. 轻量正则表达式","archived":false,"fork":false,"pushed_at":"2018-09-07T13:53:27.000Z","size":25,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T09:56:05.404Z","etag":null,"topics":["regular-expression","string","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PerfectSideRepos.png","metadata":{"files":{"readme":"README.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":"2017-02-22T15:58:57.000Z","updated_at":"2024-02-20T08:44:27.000Z","dependencies_parsed_at":"2023-01-14T14:00:31.553Z","dependency_job_id":null,"html_url":"https://github.com/PerfectSideRepos/Perfect-RegEx","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/PerfectSideRepos/Perfect-RegEx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectSideRepos%2FPerfect-RegEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectSideRepos%2FPerfect-RegEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectSideRepos%2FPerfect-RegEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectSideRepos%2FPerfect-RegEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerfectSideRepos","download_url":"https://codeload.github.com/PerfectSideRepos/Perfect-RegEx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectSideRepos%2FPerfect-RegEx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280240311,"owners_count":26296527,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["regular-expression","string","swift"],"created_at":"2025-10-21T09:56:11.897Z","updated_at":"2025-10-21T09:56:14.167Z","avatar_url":"https://github.com/PerfectSideRepos.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# String Extension of Regular Expression  [简体中文](README.zh_CN.md)\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"http://perfect.org/get-involved.html\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://perfect.org/assets/github/perfect_github_2_0_0.jpg\" alt=\"Get Involed with Perfect!\" width=\"854\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/PerfectlySoft/Perfect\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/Perfect_GH_button_1_Star.jpg\" alt=\"Star Perfect On Github\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"http://stackoverflow.com/questions/tagged/perfect\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/perfect_gh_button_2_SO.jpg\" alt=\"Stack Overflow\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"https://twitter.com/perfectlysoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/Perfect_GH_button_3_twit.jpg\" alt=\"Follow Perfect on Twitter\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"http://perfect.ly\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/Perfect_GH_button_4_slack.jpg\" alt=\"Join the Perfect Slack\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://developer.apple.com/swift/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat\" alt=\"Swift 4.0\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://developer.apple.com/swift/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Platforms-OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat\" alt=\"Platforms OS X | Linux\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://perfect.org/licensing.html\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-Apache-lightgrey.svg?style=flat\" alt=\"License Apache\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://twitter.com/PerfectlySoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Twitter-@PerfectlySoft-blue.svg?style=flat\" alt=\"PerfectlySoft Twitter\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://perfect.ly\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://perfect.ly/badge.svg\" alt=\"Slack Status\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\n\nThis project provides a light weight / simple regular expression extension for Swift String.\n\nThis package builds with Swift Package Manager and is part of the [Perfect](https://github.com/PerfectlySoft/Perfect) project. It was written to be stand-alone and so does not require PerfectLib or any other components.\n\nEnsure you have installed and activated the latest Swift 4.0 tool chain.\n\n\n## Building\nAdd this project as a dependency in your Package.swift file.\n\n``` swift\n.package(url:\"https://github.com/PerfectSideRepos/Perfect-RegEx.git\", from: \"3.1.0\")\n\n... \ndependencies: [\"Regex\"]\n```\n\nThen please add the following line to the beginning part of swift sources:\n``` swift\nimport Regex\n```\n\n## Quick Start\n\nThe following demo shows how to extract substring ranges with a pattern:\n\n``` swift\nvar source = \"there is a bloody bad bread on my bed.\"\n\nlet ranges = source.match(pattern: \"b[a-z]+d\")\n\n// it will figure out the range of `blood`, `bad` `bread` and `bed`\nlet found:[String] = ranges.map { String(source[$0]) }\nprint(\"found\", found)\n\n\n// you can do further operations, such as remove:\nsource.removeSubrange(ranges[0])\n\nprint(source)\n// the result should be:\n// there is a y bad bread on my bed.\n```\n\n## API Info\n\n\n``` swift\nextension String {\n\t/// test if the string contains certain pattern\n \t/// - parameters:\n \t///   - pattern: string to recognize\n \t/// - return: true for found\n  public func contains(pattern: String) -\u003e Bool\n\n  /// find string ranges\n  /// - parameters:\n  ///   - pattern: string to recognize\n  /// - return: a string range array\n  public func match(pattern: String) -\u003e [Range\u003cString.Index\u003e]\n}\n```\n\n## Issues\n\nWe are transitioning to using JIRA for all bugs and support related issues, therefore the GitHub issues has been disabled.\n\nIf you find a mistake, bug, or any other helpful suggestion you'd like to make on the docs please head over to [http://jira.perfect.org:8080/servicedesk/customer/portal/1](http://jira.perfect.org:8080/servicedesk/customer/portal/1) and raise it.\n\nA comprehensive list of open issues can be found at [http://jira.perfect.org:8080/projects/ISS/issues](http://jira.perfect.org:8080/projects/ISS/issues)\n\n## Further Information\nFor more information on the Perfect project, please visit [perfect.org](http://perfect.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectsiderepos%2Fperfect-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperfectsiderepos%2Fperfect-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectsiderepos%2Fperfect-regex/lists"}