{"id":13669253,"url":"https://github.com/gherkins/regexpbuilderphp","last_synced_at":"2025-04-27T01:32:55.234Z","repository":{"id":27246898,"uuid":"30719010","full_name":"gherkins/regexpbuilderphp","owner":"gherkins","description":"🦉 human-readable regular expressions","archived":false,"fork":false,"pushed_at":"2024-08-26T05:21:32.000Z","size":205,"stargazers_count":1348,"open_issues_count":0,"forks_count":49,"subscribers_count":49,"default_branch":"main","last_synced_at":"2025-04-03T17:53:11.348Z","etag":null,"topics":["human-readable","php","regex","regular-expression","regular-expressions"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/gherkins.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-12T19:16:22.000Z","updated_at":"2025-03-27T23:33:40.000Z","dependencies_parsed_at":"2024-06-18T14:08:15.645Z","dependency_job_id":"91dd0b02-672c-46fc-adea-b35ccbb89128","html_url":"https://github.com/gherkins/regexpbuilderphp","commit_stats":{"total_commits":184,"total_committers":7,"mean_commits":"26.285714285714285","dds":0.125,"last_synced_commit":"13d8d61a857d214822b6adebb0f5d48ecdd04c72"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gherkins%2Fregexpbuilderphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gherkins%2Fregexpbuilderphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gherkins%2Fregexpbuilderphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gherkins%2Fregexpbuilderphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gherkins","download_url":"https://codeload.github.com/gherkins/regexpbuilderphp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251077102,"owners_count":21532607,"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":["human-readable","php","regex","regular-expression","regular-expressions"],"created_at":"2024-08-02T08:01:07.733Z","updated_at":"2025-04-27T01:32:53.372Z","avatar_url":"https://github.com/gherkins.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"```asciidoc\n ____            _____            ____        _ _     _           ____  _   _ ____  \n|  _ \\ ___  __ _| ____|_  ___ __ | __ ) _   _(_) | __| | ___ _ __|  _ \\| | | |  _ \\ \n| |_) / _ \\/ _` |  _| \\ \\/ / '_ \\|  _ \\| | | | | |/ _` |/ _ \\ '__| |_) | |_| | |_) |\n|  _ \u003c  __/ (_| | |___ \u003e  \u003c| |_) | |_) | |_| | | | (_| |  __/ |  |  __/|  _  |  __/ \n|_| \\_\\___|\\__, |_____/_/\\_\\ .__/|____/ \\__,_|_|_|\\__,_|\\___|_|  |_|   |_| |_|_|    \n           |___/           |_|                                                      \n```\n## human-readable regular expressions for PHP\n[![release](https://img.shields.io/github/release/gherkins/regexpbuilderphp.svg?style=flat-square)](https://github.com/gherkins/regexpbuilderphp/releases)\n![release](https://img.shields.io/badge/php-%5E8.*-blue?style=flat-square)\n[![phpunit](https://img.shields.io/github/actions/workflow/status/gherkins/regexpbuilderphp/main.yml?style=flat-square\u0026color=lightgreen)](https://github.com/gherkins/regexpbuilderphp/actions)\n[![release](https://img.shields.io/badge/coverage-100%25-lightgreen?style=flat-square)](https://github.com/gherkins/regexpbuilderphp/releases)\n![release](https://img.shields.io/badge/much-wow-lightgreen?style=flat-square)\n\n\nPHP port of `regexpbuilderjs`\n\n\u003e RegExpBuilder integrates regular expressions into the programming language, thereby making them easy to read and maintain. Regular Expressions are created by using chained methods and variables such as arrays or strings.\n\n## Installation\n\n```bash\ncomposer req gherkins/regexpbuilderphp\n```\n\nOr download [the appropriate release](https://github.com/gherkins/regexpbuilderphp/releases/latest) and require `RegExpBuilder.php` and `RegExp.php` from `/src`.\n\n\n## Documentation\n\nhttps://github.com/gherkins/regexpbuilderphp/wiki\n\n\n## Examples\n\n```php\nuse Gherkins\\RegExpBuilderPHP;\n$builder = new RegExpBuilder();\n```\n\n### Validation\n\n```php\n$regExp = $builder\n    -\u003estartOfInput()\n    -\u003eexactly(4)-\u003edigits()\n    -\u003ethen(\"_\")\n    -\u003eexactly(2)-\u003edigits()\n    -\u003ethen(\"_\")\n    -\u003emin(3)-\u003emax(10)-\u003eletters()\n    -\u003ethen(\".\")\n    -\u003eanyOf(array(\"png\", \"jpg\", \"gif\"))\n    -\u003eendOfInput()\n    -\u003egetRegExp();\n\n//true\n$regExp-\u003ematches(\"2020_10_hund.jpg\");\n$regExp-\u003ematches(\"2030_11_katze.png\");\n$regExp-\u003ematches(\"4000_99_maus.gif\");\n\n//false\n$regExp-\u003ematches(\"123_00_nein.gif\");\n$regExp-\u003ematches(\"4000_0_nein.pdf\");\n$regExp-\u003ematches(\"201505_nein.jpg\");\n```\n\n### Search\n\n```php\n$regExp = $builder\n    -\u003emultiLine()\n    -\u003eglobalMatch()\n    -\u003emin(1)-\u003emax(10)-\u003eanythingBut(\" \")\n    -\u003eanyOf(array(\".pdf\", \".doc\"))\n    -\u003egetRegExp();\n\n$text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\nsed diam nonumy SomeFile.pdf eirmod tempor invidunt ut labore et dolore\nmagna aliquyam erat, sed diam voluptua. At vero eos et accusam\net justo duo dolores et ea rebum. doc_04.pdf Stet clita kasd File.doc.'\n\n$matches = $regExp-\u003efindIn($text);\n\n//true\n($matches[0] === \"SomeFile.pdf\");\n($matches[1] === \"doc_04.pdf\");\n($matches[2] === \"File.doc\");\n```\n\n### Replace\n\n```php\n$regExp = $builder\n    -\u003emin(1)\n    -\u003emax(10)\n    -\u003edigits()\n    -\u003egetRegExp();\n\n$text = \"98 bottles of beer on the wall\";\n\n$text = $regExp-\u003ereplace(\n    $text,\n    function ($match) {\n        return (int)$match + 1;\n    }\n);\n\n//true\n(\"99 bottles of beer on the wall\" === $text);\n```\n\n### Validation with multiple patterns\n\n```php\n$a = $builder\n    -\u003estartOfInput()\n    -\u003eexactly(3)-\u003edigits()\n    -\u003eanyOf(array(\".pdf\", \".doc\"))\n    -\u003eendOfInput();\n\n$b = $builder\n    -\u003egetNew()\n    -\u003estartOfInput()\n    -\u003eexactly(4)-\u003eletters()\n    -\u003ethen(\".jpg\")\n    -\u003eendOfInput();\n\n$regExp = $builder\n    -\u003egetNew()\n    -\u003eeitherFind($a)\n    -\u003eorFind($b)\n    -\u003egetRegExp();\n\n//true\n$regExp-\u003ematches(\"123.pdf\");\n$regExp-\u003ematches(\"456.doc\");\n$regExp-\u003ematches(\"bbbb.jpg\");\n$regExp-\u003ematches(\"aaaa.jpg\");\n\n//false\n$regExp-\u003ematches(\"1234.pdf\");\n$regExp-\u003ematches(\"123.gif\");\n$regExp-\u003ematches(\"aaaaa.jpg\");\n$regExp-\u003ematches(\"456.docx\");\n```\n        \nTake a look at the [tests](tests/RegExpBuilderTest.php) for more examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgherkins%2Fregexpbuilderphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgherkins%2Fregexpbuilderphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgherkins%2Fregexpbuilderphp/lists"}