How to obtain the reverse expression of a regular expression string? Regular expression regular url
I have a url rule as follows:
Mm. [* | a | B | add]. cn
Where a, B, and add indicate exceptions
For example
Mm.a.cn does not match
Mm.x.cn can be matched
How to write regular expressions ???
I only know that mm \. [a | B | add] \. cn can match all the exceptions, but I just want an inverse result?
Reply to discussion (solution)
$ S1 = 'Mm .a.cn '; $ s2 = 'Mm .add.cn'; $ s3 = 'Mm .c.cn '; $ p ='/mm \. (. + )(?
Int (0) int (0) int (1)
preg_match('#www\.(a|b|add)\.cn#',$str)
Otherwise
!preg_match('#www\.(a|b|add)\.cn#',$str)
Can only be said to LZ ?? This regular expression is hard to write.
$ S1 = 'Mm .a.cn '; $ s2 = 'Mm .add.cn'; $ s3 = 'Mm .c.cn '; $ p ='/mm \. (. + )(?
Int (0) int (0) int (1)
Try mm.aadd.cn?
$s =<<< TXTmm.a.cn mm.x.cn mm.aadd.cnmm.c.cnTXT;preg_match_all('/mm\.(?!a|b|add).*?\.cn/s', $s, $r);print_r($r);preg_match_all('/mm\.(?!a\.|b\.|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
)
)
Preg_match_all ('/mm \.(?! A \. | B \. | add \.).*? \. Cn/S', $ s, $ r );
Writeable
Preg_match_all ('/mm \.(?! (? : A | B | add )\.).*? \. Cn/S', $ s, $ r );
Preg_match_all ('/mm \.(?! A \. | B \. | add \.).*? \. Cn/S', $ s, $ r );
Writeable
Preg_match_all ('/mm \.(?! (? : A | B | add )\.).*? \. Cn/S', $ s, $ r );
Add the last character as the exclusion object? Taught
The fourth floor should be okay. paste it first.
I accidentally saw this post ..
First .. I don't understand PHP. as a regular expression, isn't it very easy ..
Exclude the characters from the negative sense:
^ Mm \. [^ AB (? : Add)] + \. cn $
[^ AB (? : Add)] --> exclude a B add
Preg_match_all ('/mm \.(?! A \. | B \. | add \.).*? \. Cn/S', $ s, $ r );
Writeable
Preg_match_all ('/mm \.(?! (? : A | B | add )\.).*? \. Cn/S', $ s, $ r );
Is this writing redundant ~