-edit- NOTE the ?
at the end of .{2,}?
I found out you can write
.{2,}?
Isnt that exactly the same as bel
Not exactly Using PHP to do a regexp match and display the capture
$string = 'aaabbaabbbaaa';
$search = preg_match_all('/b{2}a/',$string,$matches,PREG_SET_ORDER );
echo '';
var_dump($matches);
echo '
';
$search = preg_match_all('/b{2,}?a/',$string,$matches,PREG_SET_ORDER );
echo '';
var_dump($matches);
echo '
';
First result gives:
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "bba"
}
[1]=>
array(1) {
[0]=>
string(3) "bba"
}
}
second gives:
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "bba"
}
[1]=>
array(1) {
[0]=>
string(4) "bbba"
}
}
With b{2} the capture only returns 2 b's, with b{2,} it returns 2 or more