File tree Expand file tree Collapse file tree 2 files changed +85
-117
lines changed Expand file tree Collapse file tree 2 files changed +85
-117
lines changed Original file line number Diff line number Diff line change
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. " , "- " );
You can’t perform that action at this time.
0 commit comments