forked from VerbalExpressions/JSVerbalExpressions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request VerbalExpressions#4 from SignpostMarv/master
some minor tinkering
- Loading branch information
Showing
2 changed files
with
85 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.", "-"); |
Oops, something went wrong.