Skip to content

Commit ee035c0

Browse files
committed
Merge pull request VerbalExpressions#4 from SignpostMarv/master
some minor tinkering
2 parents e8b5041 + eeabe22 commit ee035c0

File tree

2 files changed

+85
-117
lines changed

2 files changed

+85
-117
lines changed

Example.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Verbal Expressions v0.1 (https://github.com/jehna/VerbalExpressions) ported in PHP
4+
* @author Mihai Ionut Vilcu ([email protected])
5+
* 22.July.2013
6+
*/
7+
8+
require_once('VerbalExpressions.php');
9+
10+
11+
$regex = new VerEx;
12+
13+
$regex ->startOfLine()
14+
->then( "http" )
15+
->maybe( "s" )
16+
->then( "://" )
17+
->maybe( "www." )
18+
->anythingBut( " " )
19+
->endOfLine();
20+
21+
22+
if($regex->test("http://github.com"))
23+
echo "valid url". '<br>';
24+
else
25+
echo "invalid url". '<br>';
26+
27+
if (preg_match($regex, 'http://github.com')) {
28+
echo 'valid url';
29+
} else {
30+
echo 'invalud url';
31+
}
32+
33+
echo "<pre>". $regex->getRegex() ."</pre>";
34+
35+
36+
echo $regex ->clean(array("modifiers"=> "m","replaceLimit"=>4))
37+
->find(' ')
38+
->replace("This is a small test http://somesite.com and some more text.", "-");

0 commit comments

Comments
 (0)