Skip to content

Commit

Permalink
Merge pull request VerbalExpressions#4 from SignpostMarv/master
Browse files Browse the repository at this point in the history
some minor tinkering
  • Loading branch information
mihai-vlc committed Aug 11, 2013
2 parents e8b5041 + eeabe22 commit ee035c0
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 117 deletions.
38 changes: 38 additions & 0 deletions Example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Verbal Expressions v0.1 (https://github.com/jehna/VerbalExpressions) ported in PHP
* @author Mihai Ionut Vilcu ([email protected])
* 22.July.2013
*/

require_once('VerbalExpressions.php');


$regex = new VerEx;

$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 'invalud 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.", "-");
Loading

0 comments on commit ee035c0

Please sign in to comment.