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 10
10
$ regex = new \VerbalExpressions \PHPVerbalExpressions \VerbalExpressions ();
11
11
12
12
$ 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
+ }
24
25
25
26
if (preg_match ($ regex , 'http://github.com ' )) {
26
- echo 'valid url ' ;
27
+ echo 'valid url ' ;
27
28
} else {
28
- echo 'invalud url ' ;
29
+ echo 'invalid url ' ;
29
30
}
30
31
31
32
echo "<pre> " . $ regex ->getRegex () ."</pre> " ;
32
33
33
34
echo $ 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. " , "- " );
36
37
37
38
38
39
echo "<hr> " ;
39
40
40
41
// limit
41
42
echo $ 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 " );
48
49
49
50
echo "<br> " ;
50
51
51
52
52
53
53
54
echo $ 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
10
10
11
11
// some tests
12
12
13
- $regex = new VerbalExpressions;
13
+ $regex = new VerbalExpressions() ;
14
14
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();
22
22
23
23
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
+ }
28
29
29
30
if (preg_match($regex, 'http://github.com')) {
30
31
echo 'valid url';
@@ -35,11 +36,9 @@ if (preg_match($regex, 'http://github.com')) {
35
36
36
37
echo "<pre >". $regex->getRegex() ."</pre >";
37
38
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.", "-");
43
42
44
43
```
45
44
Original file line number Diff line number Diff line change 4
4
"type" : " project" ,
5
5
"description" : " PHP Regular expressions made easy" ,
6
6
"require" : {
7
- "php" : " >=5.6" ,
8
- "squizlabs/php_codesniffer" : " ^3.1"
7
+ "php" : " >=5.6"
9
8
},
10
9
"require-dev" : {
11
- "phpunit/phpunit" : " * >=4"
10
+ "phpunit/phpunit" : " * >=4" ,
11
+ "squizlabs/php_codesniffer" : " ^3.1"
12
12
},
13
13
"minimum-stability" : " stable" ,
14
14
"autoload" : {
You can’t perform that action at this time.
0 commit comments