Simple regular expression $ ss & nbsp; [$? [W.] +]; preg_match_all ($ ss, & nbsp; [abc], & nbsp; $ mat); [$ abc] & nbsp; [abc] why cannot I match? ------ solution -------------------- $ simple regular expression
$ Ss = "/\ [\ $? [\ W \.] + \]/";
Preg_match_all ($ ss, "[abc]", $ mat); // [$ abc] [abc] cannot be matched
------ Solution --------------------
$ Ss = "/\ [\\$? [\ W] + \]/";
Preg_match_all ($ ss, '[abc] vv [$ def]', $ mat );
Print_r ($ mat );
Array
(
[0] => Array
(
[0] => [abc]
[1] => [$ def]
)
)
------ Solution --------------------
Reference:
Reference: csdn is a mess...
$ Ss = "/\ [\\$? [\ W \.] + \]/";
Or
$ Ss = '/\ [\ $? [\ W \.] + \]/';
4th Floor
$ Ss = '/\ [\ $? [\ W \.] + \]/'why can't [abc] it be matched?
Why cannot It be matched?
Yes. Have you tried ??
$ No Escape refers to a variable.
In "", \ $ also refers to the variable... Therefore, the escape character "$" is required.