Regular expression difficulty this post was last edited by xjl756213616 from 2013-03-0721: 02: 34 & lt ;? Php $ a = "a11ba12b"; preg_match_all ("/(a [^ B] + B) {2}/is", $ a, $ tmp ); var_dump ($ tm regular expression problem
This post was last edited by xjl756213616 at 21:02:34
$a="a11ba12b";
preg_match_all("/(a[^b]+b){2}/is",$a,$tmp);
var_dump($tmp);
?>
The result is:
array(2) {
[0]=>
array(1) {
[0]=>
string(8) "a11ba12b"
}
[1]=>
array(1) {
[0]=>
string(4) "a12b"
}
}
Now, I want to ask how to use the {} brackets notation, but in [1], it is = a11b, not [1] = a12b,
------ Solution --------------------
\ G?
$a="a11ba11b";
preg_match_all("/\G(a[^b]+b){2}/i",$a,$tmp);
var_dump($tmp);
------ Solution --------------------
.. Baoqian
Seemingly wrong
------ Solution --------------------
It is better to specify the greedy mode.
Preg_match_all ("/(a [^ B] + B) +/iU", $ a, $ tmp );
Wait for the answer.
------ Solution --------------------
So? What are you doing?
$a="a11ba12b";
preg_match_all("/(a[^b]+b)a[^b]+b/is",$a,$tmp);
var_dump($tmp);
------ Solution --------------------
Reference:
I am studying braces, haha
What can be studied? Rules are rules
{Minimum/maximum quantity limit start
} The minimum/maximum quantity limit ends.
Although the rules are sometimes unreasonable, they won't change because of you.