Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

PHPVerbalExpressions

> 后端框架
Open source

PHP Regular expressions made easy

2.4K stars0 likes4 views
WebsiteGitHub

About

PHP Regular expressions made easy

PHPVerbalExpressions

  • ported from VerbalExpressions

VerbalExpressions is a PHP library that helps to construct hard regular expressions.

Installation

The project supports Composer so you have to install Composer first, before project setup.

bash
$ composer require  verbalexpressions/php-verbal-expressions:dev-master

Examples

…

More examples are available in the following files:

  • Example.php
  • VerbalExpressionsTest.php

Business readable language expression definition

php
$definition = 'start, then "http", maybe "s", then "://", maybe "www.", anything but " ", end';
$regex = new VerbalExpressionsScenario($definition);

Methods list

Name Description Usage
add add values to the expression add('abc')
startOfLine mark expression with ^ startOfLine(false)
endOfLine mark the expression with $ endOfLine()
then add a string to the expression add('foo')
find alias for then find('foo')
maybe define a string that might appear once or not maybe('.com')
anything accept any string anything()
anythingBut accept any string but the specified char anythingBut(',')
something accept any non-empty string something()
somethingBut anything non-empty except for these chars somethingBut('a')
replace shorthand for preg_replace() replace($source, $val)
lineBreak match \r \n lineBreak()
br shorthand for lineBreak br()
tab match tabs \t tab()
word match \w+ word()
anyOf any of the listed chars anyOf('abc')
any shorthand for anyOf any('abc')
range adds a range to the expression range(a,z,0,9)
withAnyCase match case default case sensitive withAnyCase()
stopAtFirst toggles the g modifiers stopAtFirst()
addModifier add a modifier addModifier('g')
removeModifier remove a mofier removeModifier('g')
searchOneLine Toggles m modifier searchOneLine()
multiple adds the multiple modifier multiple('*')
_or wraps the expression in an or with the provided value _or('bar')
limit adds char limit limit(1,3)
test performs a preg_match test('[email protected]')

For all the above method (except test) you could use the VerbalExpressionsScenario.

Other Implementations

You can see an up to date list of all ports on VerbalExpressions.github.io.

  • Javascript
  • Ruby
  • C#
  • Python
  • Java
  • C++

Building the project and running the tests

The project supports Composer so you have to install Composer first before project setup.

bash
curl -sS https://getcomposer.org/installer | php
php composer.phar install --dev
ln -s vendor/phpunit/phpunit/phpunit.php phpunit
./phpunit

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPregular-expressionverbalexpressions

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架