Reputation: 49
I'm kinda of new to PHP, can you please clarify about the below preg_match.
preg_match("/^(9)\1+$/",$value);
Upvotes: 1
Views: 91
Reputation: 490183
It will match a string that consists of two or more 9
s.
The regex is weird, and not typical of its intention IMO. I'd write it as...
/^9{2,}\z/
Upvotes: 4
Reputation: 1250
preg_match($arg1, $arg2);
$arg1 - regular expression $arg1 is being searched/matchedin $arg2
for more help refer this link: http://php.net/manual/en/function.preg-match.php
for regular expressions: http://www.regular-expressions.info/examples.html
In the example you gave: The regular expression "/^(9)\1+$/" - Starts(^) with 9 and have more than 1 (\1+ which means 2 or more) 9's and ends($) with 9
So this is being searched in the $value. Hope it is clear.
Upvotes: -1