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.
transferring example code to Example.php
- Loading branch information
1 parent
5f0c272
commit 337f9a3
Showing
2 changed files
with
38 additions
and
32 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"; | ||
else | ||
echo "invalid url"; | ||
|
||
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.", "-"); |
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