File tree Expand file tree Collapse file tree 3 files changed +46
-54
lines changed
Expand file tree Collapse file tree 3 files changed +46
-54
lines changed Original file line number Diff line number Diff line change 1010$ regex = new \VerbalExpressions \PHPVerbalExpressions \VerbalExpressions ();
1111
1212$ regex ->startOfLine ()
13- ->then ("http " )
14- ->maybe ("s " )
15- ->then (":// " )
16- ->maybe ("www. " )
17- ->anythingBut (" " )
18- ->endOfLine ();
19-
20- if ($ regex ->test ("http://github.com " ))
21- echo "valid url " . '<br> ' ;
22- else
23- echo "invalid url " . '<br> ' ;
13+ ->then ("http " )
14+ ->maybe ("s " )
15+ ->then (":// " )
16+ ->maybe ("www. " )
17+ ->anythingBut (" " )
18+ ->endOfLine ();
19+
20+ if ($ regex ->test ("http://github.com " )) {
21+ echo "valid url " . '<br> ' ;
22+ } else {
23+ echo "invalid url " . '<br> ' ;
24+ }
2425
2526if (preg_match ($ regex , 'http://github.com ' )) {
26- echo 'valid url ' ;
27+ echo 'valid url ' ;
2728} else {
28- echo 'invalud url ' ;
29+ echo 'invalid url ' ;
2930}
3031
3132echo "<pre> " . $ regex ->getRegex () ."</pre> " ;
3233
3334echo $ regex ->clean (array ("modifiers " => "m " , "replaceLimit " => 4 ))
34- ->find (' ' )
35- ->replace ("This is a small test http://somesite.com and some more text. " , "- " );
35+ ->find (' ' )
36+ ->replace ("This is a small test http://somesite.com and some more text. " , "- " );
3637
3738
3839echo "<hr> " ;
3940
4041// limit
4142echo $ regex ->clean (array ("modifiers " => "m " ))
42- ->startOfLine ()
43- ->anyOf ("abc " )
44- ->anythingBut (" " )
45- ->limit (1 )
46- ->withAnyCase ()
47- ->replace ("Abracadabra is a nice word " , "Ba " );
43+ ->startOfLine ()
44+ ->anyOf ("abc " )
45+ ->anythingBut (" " )
46+ ->limit (1 )
47+ ->withAnyCase ()
48+ ->replace ("Abracadabra is a nice word " , "Ba " );
4849
4950echo "<br> " ;
5051
5152
5253
5354echo $ regex ->clean (array ("modifiers " => "gm " ))
54- ->add ("\b " )
55- ->word ()
56- ->limit (2 , 3 )
57- ->add ("\b " )
58- ->replace ("test abc ab abcd " , "* " );
59-
60-
61-
62-
63-
64-
65-
66-
55+ ->add ("\b " )
56+ ->word ()
57+ ->limit (2 , 3 )
58+ ->add ("\b " )
59+ ->replace ("test abc ab abcd " , "* " );
Original file line number Diff line number Diff line change @@ -10,21 +10,22 @@ VerbalExpressions is a PHP library that helps to construct hard regular expressi
1010
1111// some tests
1212
13- $regex = new VerbalExpressions;
13+ $regex = new VerbalExpressions() ;
1414
15- $regex ->startOfLine()
16- ->then("http")
17- ->maybe("s")
18- ->then("://")
19- ->maybe("www.")
20- ->anythingBut(" ")
21- ->endOfLine();
15+ $regex->startOfLine()
16+ ->then("http")
17+ ->maybe("s")
18+ ->then("://")
19+ ->maybe("www.")
20+ ->anythingBut(" ")
21+ ->endOfLine();
2222
2323
24- if($regex->test("https://github.com/"))
25- echo "valid url";
26- else
27- echo "invalid url";
24+ if ($regex->test("http://github.com")) {
25+ echo "valid url". '<br >';
26+ } else {
27+ echo "invalid url". '<br >';
28+ }
2829
2930if (preg_match($regex, 'http://github.com')) {
3031 echo 'valid url';
@@ -35,11 +36,9 @@ if (preg_match($regex, 'http://github.com')) {
3536
3637echo "<pre >". $regex->getRegex() ."</pre >";
3738
38-
39-
40- echo $regex ->clean(array("modifiers" => "m", "replaceLimit" => 4))
41- ->find(' ')
42- ->replace("This is a small test http://somesite.com and some more text.", "-");
39+ echo $regex->clean(array("modifiers" => "m", "replaceLimit" => 4))
40+ ->find(' ')
41+ ->replace("This is a small test http://somesite.com and some more text.", "-");
4342
4443```
4544
Original file line number Diff line number Diff line change 44 "type" : " project" ,
55 "description" : " PHP Regular expressions made easy" ,
66 "require" : {
7- "php" : " >=5.6" ,
8- "squizlabs/php_codesniffer" : " ^3.1"
7+ "php" : " >=5.6"
98 },
109 "require-dev" : {
11- "phpunit/phpunit" : " * >=4"
10+ "phpunit/phpunit" : " * >=4" ,
11+ "squizlabs/php_codesniffer" : " ^3.1"
1212 },
1313 "minimum-stability" : " stable" ,
1414 "autoload" : {
You can’t perform that action at this time.
0 commit comments