Evaluate a regular expression, and the content must be assertion to the negative zero width.
1234567890234123789
I only want to match the content that is not in it.
7890234123789
The following is my own regular expression, but it is not successful.
(?!)
Reply to discussion (solution)
I had to wait online.
123789 is not in, do you want to match characters that do not appear in the first one?
The string processing function can be used to locate the first one, take the header and tail position, and then process the string.
We recommend that you first separate the strings by carriage return and then perform regular matching on each substring.
I want to understand the meaning of the assertion of negative and zero width. I don't know who can write this regular expression.
You have not solved your problem, but encountered a strange problem during the solution.
$ Str = <
)/', $ Str, $ m); // [0] => 123456preg_match_all ('/(?
)/', $ Str, $ t1 ); /* [0] => 2345 [1] => 7890234 [2] => 23 [3] => 78. only 123 can be obtained if the number is tested separately. to 23 */$ str_space = <
)/', $ Str_space, $ t2 ); /* you can add a space to the adjacent number. [0] => 123456 [1] => 7890234 [2] => 123 [3] => 789 */ echo"
";print_r($m);print_r($t1);print_r($t2);echo "
";
Thank you!
Good morning. can't you solve this problem?
It is easy to match only 123456
You have deleted it. do you want the rest?
$s =<<< TXT1234567890234123789TXT;$p = '#\d+[\r\n]+#';preg_match_all("/[^\r\n]+/", preg_replace($p, '', $s), $m);print_r($m);
Array( [0] => Array ( [0] => 7890234 [1] => 123 [2] => 789 ))
It must be noted that php's regular expressions do not fully implement all functions of modern regular expressions, and the implementation of assertions is incomplete.
If you want to learn regular expressions, you should do so in the C # and Java environments.
If you need to use it, you should use it with your own brains.
Regular expressions are supported by the PCRE (Perl Compatible Regular Expression) library. this is an open source software written by Philip Hazel, copyright belongs to the University of Cambridge. You can obtain it at: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre /.