{"id":20594625,"url":"https://github.com/koca/easyregex","last_synced_at":"2026-03-14T06:33:33.262Z","repository":{"id":57007889,"uuid":"59922071","full_name":"koca/EasyRegex","owner":"koca","description":"EasyRegex is a PHP library that helps to construct hard regular expressions.","archived":false,"fork":false,"pushed_at":"2016-07-27T05:35:16.000Z","size":12,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T04:39:59.733Z","etag":null,"topics":["php","php-library","regex"],"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/koca.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":"2016-05-29T01:55:32.000Z","updated_at":"2022-07-07T08:58:39.000Z","dependencies_parsed_at":"2022-08-21T14:31:19.901Z","dependency_job_id":null,"html_url":"https://github.com/koca/EasyRegex","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koca%2FEasyRegex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koca%2FEasyRegex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koca%2FEasyRegex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koca%2FEasyRegex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koca","download_url":"https://codeload.github.com/koca/EasyRegex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248979614,"owners_count":21193005,"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":["php","php-library","regex"],"created_at":"2024-11-16T08:09:37.105Z","updated_at":"2026-03-14T06:33:33.206Z","avatar_url":"https://github.com/koca.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Easy Regex\n- ported from [VerbalExpressions](https://github.com/VerbalExpressions/PHPVerbalExpressions)\n\nEasyRegex is a PHP library that helps to construct hard regular expressions.  \n\n## Install\n\n```\n$ composer require koca/easyregex\n```\n\n## Usage\n\n```php\n// some tests\nuse Koca\\EasyRegex\\EasyRegex;\n\n$regex = new EasyRegex;\n\n$regex  -\u003estartOfLine()\n        -\u003ethen(\"http\")\n        -\u003emaybe(\"s\")\n        -\u003ethen(\"://\")\n        -\u003emaybe(\"www.\")\n        -\u003eanythingBut(\" \")\n        -\u003eendOfLine();\n\n\nif($regex-\u003etest(\"https://github.com/\"))\n    echo \"valid url\";\nelse\n    echo \"invalid url\";\n\nif (preg_match($regex, 'http://github.com')) {\n    echo 'valid url';\n} else {\n    echo 'invalid url';\n}\n\n\necho \"\u003cpre\u003e\". $regex-\u003egetRegex() .\"\u003c/pre\u003e\";\n\n\n\necho $regex -\u003eclean(array(\"modifiers\" =\u003e \"m\", \"replaceLimit\" =\u003e 4))\n            -\u003efind(' ')\n            -\u003ereplace(\"This is a small test http://somesite.com and some more text.\", \"-\");\n\n```\n\n### Regex Capturing\n\n```php\n\n$regex-\u003efind(\"You have \")\n    -\u003ebeginCapture(\"count\")\n    -\u003eword()\n    -\u003eendCapture();\n\n$contributions = $regex-\u003ematch(\"You have 258 contributions in the last year\");\n\necho $contributions[\"count\"];\n\n// Output: 258\n\n``` \n\n##Methods list\n\nName|Description|Usage\n:---|:---|:---\nadd| add values to the expression| add('abc')\nstartOfLine| mark expression with ^| startOfLine(false)\nendoOfLine| mark the expression with $|endOfLine()\nthen|add a string to the expression| add('foo')\nfind| alias for then| find('foo')\nmaybe| define a string that might appear once or not| maybe('.com')\nanything| accept any string| anything()\nanythingUntil | Anything up until given sequence of characters| anythingUntil('.com')\nanythingBut| accept any string but the specified char| anythingBut(',')\nsomething| accept any non-empty string| something()\nsomethingBut| anything non-empty except for these chars| somethingBut('a')\nreplace| shorthand for preg_replace()| replace($source, $val)\nlineBreak| match \\r \\n|lineBreak()\nbr|shorthand for lineBreak| br()\ntab|match tabs \\t |tab()\nword|match \\w+|word()\nanyOf| any of the listed chars| anyOf('abc')\nany| shorthand for anyOf| any('abc')\nrange| adds a range to the expression|range(a,z,0,9)\nwithAnyCase| match case default case sensitive|withAnyCase()\nbeginCapture| Capture groups (can optionally name)| beginCapture(\"bar\")\nendCapture| Stop capture| endCapture()\nmatch| Shorthand method for preg_match| match(\"long string\")\nmatchAll| Shorthand method for preg_match_all| matchAll(\"long string\")\nstopAtFirst|toggles the g modifiers|stopAtFirst()\naddModifier| add a modifier|addModifier('g')\nremoveModifier| remove a mofier|removeModifier('g')\nsearchOneLine| Toggles m modifier|searchOneLine()\nmultiple|adds the multiple modifier| multiple('*')\n_or|wraps the expression in an `or` with the provided value|_or('bar')\nlimit|adds char limit|limit(1,3)\ntest| performs a preg_match| test('valid@email.com')\n\n\n## Building the project and running the tests\nThe project supports Composer so you have to install [Composer](https://getcomposer.org/doc/00-intro.md#installation-nix) first before project setup.\n\n    curl -sS https://getcomposer.org/installer | php\n    php composer.phar install --dev\n    ln -s vendor/phpunit/phpunit/phpunit.php phpunit\n    ./phpunit\n    \n\n## License\n\nThis project is free and open source software, distributed under the [MIT License](/LICENSE) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoca%2Feasyregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoca%2Feasyregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoca%2Feasyregex/lists"}