Skip to content

Commit

Permalink
transferring example code to Example.php
Browse files Browse the repository at this point in the history
  • Loading branch information
SignpostMarv committed Aug 11, 2013
1 parent 5f0c272 commit 337f9a3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 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";
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.", "-");
32 changes: 0 additions & 32 deletions VerbalExpressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,6 @@
*/


// // some tests

// $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.", "-");


class VerEx {

public $prefixes = "";
Expand Down

0 comments on commit 337f9a3

Please sign in to comment.