Skip to content

Commit 337f9a3

Browse files
committed
transferring example code to Example.php
1 parent 5f0c272 commit 337f9a3

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
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";
24+
else
25+
echo "invalid url";
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.", "-");

VerbalExpressions.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,6 @@
66
*/
77

88

9-
// // some tests
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";
24-
// else
25-
// echo "invalid url";
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.", "-");
39-
40-
419
class VerEx {
4210

4311
public $prefixes = "";

0 commit comments

Comments
 (0)