Regular expression, requires a negative 0-wide assertion

Source: Internet
Author: User
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/.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.