All Projects → VerbalExpressions → Phpverbalexpressions

VerbalExpressions / Phpverbalexpressions

Licence: mit
PHP Regular expressions made easy

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Phpverbalexpressions

Braces
Faster brace expansion for node.js. Besides being faster, braces is not subject to DoS attacks like minimatch, is more accurate, and has more complete support for Bash 4.3.
Stars: ✭ 133 (-94.41%)
Mutual labels:  regular-expression
Router
⚡️ A lightning fast HTTP router
Stars: ✭ 158 (-93.36%)
Mutual labels:  regular-expression
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (-92.65%)
Mutual labels:  regular-expression
Micromatch
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Stars: ✭ 1,979 (-16.85%)
Mutual labels:  regular-expression
Find
A find-in-page extension for Chrome and Firefox that supports regular expressions.
Stars: ✭ 157 (-93.4%)
Mutual labels:  regular-expression
Parseback
A Scala implementation of parsing with derivatives
Stars: ✭ 168 (-92.94%)
Mutual labels:  regular-expression
Dan Jurafsky Chris Manning Nlp
My solution to the Natural Language Processing course made by Dan Jurafsky, Chris Manning in Winter 2012.
Stars: ✭ 124 (-94.79%)
Mutual labels:  regular-expression
Automata.js
A regular expression converter
Stars: ✭ 202 (-91.51%)
Mutual labels:  regular-expression
Jsverbalexpressions
JavaScript Regular expressions made easy
Stars: ✭ 11,886 (+399.41%)
Mutual labels:  verbalexpressions
Ocaml Re
Pure OCaml regular expressions, with support for Perl and POSIX-style strings
Stars: ✭ 172 (-92.77%)
Mutual labels:  regular-expression
Regex Dos
👮 👊 RegEx Denial of Service (ReDos) Scanner
Stars: ✭ 143 (-93.99%)
Mutual labels:  regular-expression
Srl Php
Simple Regex Language
Stars: ✭ 1,808 (-24.03%)
Mutual labels:  regular-expression
Regularexpressiondecoder
A decoder that constructs objects from regular expression matches.
Stars: ✭ 169 (-92.9%)
Mutual labels:  regular-expression
Wayeb
Wayeb is a Complex Event Processing and Forecasting (CEP/F) engine written in Scala.
Stars: ✭ 138 (-94.2%)
Mutual labels:  regular-expression
Xo
Command line utility that composes regular expression matches.
Stars: ✭ 184 (-92.27%)
Mutual labels:  regular-expression
Randexp.js
Create random strings that match a given regular expression.
Stars: ✭ 1,682 (-29.33%)
Mutual labels:  regular-expression
Grex
A command-line tool and library for generating regular expressions from user-provided test cases
Stars: ✭ 4,847 (+103.66%)
Mutual labels:  regular-expression
String Replace Loader
Replace loader for Webpack
Stars: ✭ 205 (-91.39%)
Mutual labels:  regular-expression
Regexpu
A source code transpiler that enables the use of ES2015 Unicode regular expressions in ES5.
Stars: ✭ 201 (-91.55%)
Mutual labels:  regular-expression
Regex.persian.language
Collection of Regex for validating, filtering, sanitizing and finding Persian strings
Stars: ✭ 172 (-92.77%)
Mutual labels:  regular-expression

Build Status

PHPVerbalExpressions

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.

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

Examples

<?php
// some tests
require './vendor/autoload.php';
use VerbalExpressions\PHPVerbalExpressions\VerbalExpressions;

$regex = new VerbalExpressions();

$regex->startOfLine()
      ->then("http")
      ->maybe("s")
      ->then("://")
      ->maybe("www.")
      ->anythingBut(" ")
      ->endOfLine();


if ($regex->test("http://github.com")) {
    echo "valid url". '<br>';
} else {
    echo "invalid url". '<br>';
}

if (preg_match($regex, 'http://github.com')) {
    echo 'valid url';
} else {
    echo 'invalid url';
}


echo "<pre>". $regex->getRegex() ."</pre>";

echo $regex->clean(array("modifiers" => "m", "replaceLimit" => 4))
           ->find(' ')
           ->replace("This is a small test http://somesite.com and some more text.", "-");

More examples are available in the following files:

Business readable language expression definition

$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.

Building the project and running the tests

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

curl -sS https://getcomposer.org/installer | php
php composer.phar install --dev
ln -s vendor/phpunit/phpunit/phpunit.php phpunit
./phpunit
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].