A fluent php api for regular expressions.
Alternatives To Xpressions
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Regexpbuilderphp1,264362 months ago12January 09, 2023mitPHP
🦉 human-readable regular expressions
Truemail1,117412 days ago85October 31, 2023mitRuby
🚀 Configurable framework agnostic plain Ruby 📨 email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists.
Deep Email Validator733610 months ago22December 21, 202129mitTypeScript
Validates regex, typos, disposable, dns and smtp
Commonregex59510114 years ago2December 08, 20181mitGo
🍫 A collection of common regular expressions for Go
13 years ago21Objective-C
Objective-C interactive regular expression validator and tester for OS X.
Smvalidator33317 years ago5October 18, 2016mitJavaScript
a simple but powerful tool for validating form fields. support bootstrap and your own styles.
Terraform_validate22814 years ago22May 16, 201814gpl-3.0Python
Assists in the enforcement of user-defined standards in Terraform
Schema Typed1882887 months ago26May 06, 20239mitJavaScript
Schema for data modeling & validation
Validetta1721425 years ago2February 19, 20172mitJavaScript
A tiny jquery plugin for validate forms
Valdr159437 years ago6September 14, 201629mitJavaScript
A model centric approach to AngularJS form validation
Alternatives To Xpressions
Select To Compare

Alternative Project Comparisons


A fluent PHP API for regular expressions.


Xpressions now is not ready for production yet, but you can install it using composer via:

composer require alshahawi/xpressions:dev-master


Creating an instance

$matcher = Xpressions::match();

Matchting a string

$matcher = Xpressions::match()->exact('foo');

var_dump($matcher->test('bar')); // -> false
var_dump($matcher->test('foo')); // -> true

Inline Matching

In some situations (like validation) you might want to match something in the start of the line and before the end of that line, in that case you might use begin() and end() methods. For example:

$matcher = Xpressions::match()->begin()->exact('bar')->end();

var_dump($matcher->test('foo bar')); // -> false
var_dump($matcher->test('bar foo')); // -> false
var_dump($matcher->test('bar'));     // -> true

NOTE: without begin() and end() all of the above tests will match (returning true), because whatever the matched in the start or the end of the line will return true unless you specified the begin and the end of the line (the whole text).

Matching an optional string

$matcher = Xpressions::match()->exact('foo')->maybe('bar')->exact('baz');

var_dump($matcher->test('foo'));       // -> false
var_dump($matcher->test('foobar'));    // -> false
var_dump($matcher->test('foobarbaz')); // -> true
var_dump($matcher->test('foobaz'));    // -> true

Matching alphanumeric & underscores

$matcher = Xpressions::match()->word();

var_dump($matcher->test('!')); // -> false
var_dump($matcher->test('a')); // -> true
var_dump($matcher->test('1')); // -> true
var_dump($matcher->test('_')); // -> true

You may use words() to match a one or more word characters.

You may use nonWord() as an inverse to this method.

Matching a digit

$matcher = Xpressions::match()->digit();

var_dump($matcher->test('!')); // -> false
var_dump($matcher->test('a')); // -> false
var_dump($matcher->test('1')); // -> true

You may use digits() to match a one or more word characters.

You may use nonDigit() as an inverse to this method.

Matching any of a given values

$matcher = Xpressions::match()->any('foo', 'bar', 'baz');

var_dump($matcher->test('something')); // -> false
var_dump($matcher->test('foo'));       // -> true
var_dump($matcher->test('bar'));       // -> true
var_dump($matcher->test('baz'));       // -> true

Advanced Examples

Matching an email address

$matcher = Xpressions::match()
    ->begin() // match a line start
    ->oneOrMore(function($xpr) {
    ->oneOrMore(function($xpr) {
    ->end(); // match a line end

var_dump($matcher->test('invalid'));        // ->false
var_dump($matcher->test('[email protected]')); // ->true

Interested in more advanced examples?

Many of examples will be written and documented soon!, but you can view tests/XpressionsTest.php for now.

Popular Regular Expression Projects
Popular Validation Projects
Popular Text Processing Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Regular Expression