How does the regular expression string get reversed?
I have a URL rule as follows:
mm.[*|a|b|add].cn
Where A, B, add represents an exception
For example
Mm.a.cn cannot match
Mm.x.cn can match
How to write the regular???
All I know is mm\. [a|b|add]\.cn can match all exceptions, but I just want a reverse result?]
Regular Expressions Regular URL
Share to:
------Solution--------------------
$s 1= ' mm.a.cn ';
$s 2= ' mm.add.cn ';
$s 3= ' mm.c.cn ';
$p = '/mm\. (.+) (?
------Solution--------------------
B
------Solution--------------------
Add) \.cn/';
$bool 1=preg_match ($p, $s 1);
$bool 2=preg_match ($p, $s 2);
$bool 3=preg_match ($p, $s 3);
Var_dump ($bool 1, $bool 2, $bool 3);
int (0) int (0) int (1)
------Solution--------------------
Preg_match (' #www \. ( A
------Solution--------------------
B
------Solution--------------------
Add) \.cn# ', $str)
If it doesn't match.
!preg_match (' #www \. ( A
------Solution--------------------
B
------Solution--------------------
Add) \.cn# ', $str)
------Solution--------------------
Can only say to LZ-this is hard to write
References:
$s 1= ' mm.a.cn ';
$s 2= ' mm.add.cn ';
$s 3= ' mm.c.cn ';
$p = '/mm\. (.+) (?
------Solution--------------------
B
------Solution--------------------
Add) \.cn/';
$bool 1=preg_match ($p, $s 1);
$bool 2=preg_match ($p, $s 2);
$bool 3=preg_match ($p, $s 3);
Var_dump ($bool 1, $bool 2, $bool 3);
int (0) int (0) int (1)
Try mm.aadd.cn?
------Solution--------------------
$s =<<< TXT
mm.aadd.cn
mm.c.cn
TXT;
Preg_match_all ('/mm\. A
------Solution--------------------
B
------Solution--------------------
Add). *?\.cn/s ', $s, $r);
Print_r ($R);
Preg_match_all ('/mm\. A\.
------Solution--------------------
B\.
------Solution--------------------
Add\.). *?\.CN/S ', $s, $r);
Print_r ($R);
Array
(
[0] = = Array
(
[0] = mm.x.cn
[1] = mm.c.cn
)
)
Array
(
[0] = = Array
(
[0] = mm.x.cn
[1] = mm.aadd.cn
[2] = mm.c.cn
)
)
------Solution--------------------
Preg_match_all ('/mm\. A\.
------Solution--------------------
B\.
------Solution--------------------
Add\.). *?\.CN/S ', $s, $r);
Can write
Preg_match_all ('/mm\. (?: A
------Solution--------------------
B
------Solution--------------------
Add) \.). *?\.CN/S ', $s, $r);
------Solution--------------------
preg_match_all ('/mm\. A\.
------Solution--------------------
B\.
------Solution--------------------
add\.). *?\.CN/S ', $s, $r);
can write
Preg_match_all ('/mm\. (?: a
------solution--------------------
B
------Solution--------------------
Add) \.). *?\.CN/S ', $s, $r);