To find a regular expression, a negative 0-wide assertion is required
Content
123456
7890234
123
789
I just want to match the content that is not inside, that needs to match to
7890234
123
789
The following is my own writing of the regular, but did not succeed, hope advice
(?!)
------to solve the idea----------------------
Did not solve your problem, but encountered a strange problem in the process of solving
$str = <<
<>
123456
7890234
123
789
EOF;
There is one in the Handbook (?! pattern) Negative pre-check should be the meaning of "negative 0 wide assertion"
Preg_match_all ('/(<=) \d+ (?=<\/a>)/', $STR, $m);//[0] = 123456
Preg_match_all ('/(?
) /', $STR, $t 1);
/*
With or adjacent numbers are not obtained to
[0] = 2345
[1] = 7890234
[2] = 23
[3] = 78
Individual Test 123
Also can only get to 23
*/
$str _space = <<
<>
7890234
123
EOF;
Preg_match_all ('/(?
) /', $str _space, $t 2);
/*
And a space on or adjacent to the number.
[0] = 123456
[1] = 7890234
[2] = 123
[3] = 789
*/
echo "";
Print_r ($m);
Print_r ($t 1);
Print_r ($t 2);
echo "
";
------to solve the idea----------------------
It's easy to match only to 123456.
Did you delete it and the rest is what you asked for?
$s =<<< TXT
123456
7890234
123
789
TXT;
$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 explained that the regular expression of PHP does not fully implement the full functionality of the modern regular expression, the implementation of the assertion is incomplete
If you want to learn about regular expressions, you should do so in C # and Java environments
If you are in need of practical use, then you should use your brains and work
Support for regular expressions is provided by the PCRE (Perl Compatible Regular expression) library, an open source software that is written by Philip Hazel and is copyrighted by the University of Cambridge. Can be obtained at the following address: Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/.