If you are familiar with regular expressions and use repeated expressions in the 0-width assertion *, an error will be reported. Solution

Source: Internet
Author: User
Tags perl regular expression php regular expression expression engine
If you are familiar with regular expressions and use repeated expressions in 0-width assertions *, an error will be reported. PHPcodepreg_match (#(? & Lt; a *) word #, preword, $ mt); preg_match (#(? & Lt; (w +) & gt ;).*(? & Lt; 1 & gt;) #, pre & lt; a & gt; hi! & Lt; a & gt; word, $ m when familiar with regular expressions come in, the 0-width assertion repeats * will report an error
Let's take a look at the two.
PHP code
  Preg_match ('#(? <= A *) word # ', 'pre word', $ mt); preg_match ('#(? <= <(\ W +)> ).*(? = <\/\ 1>) # ', 'prehi! Word', $ mt );



------ Solution --------------------
Http://perldoc.perl.org/perlretut.html#Looking-ahead-and-looking-behind
This is a perl regular expression document and I think it should be applicable to the php regular expression engine.
The lookahead assertion is denoted (? = Regexp) and the lookbehind assertion is denoted (? <= Fixed-regexp)
The zero-width assertion is also called the loop View. the above meaning is that the reverse-order loop view can only contain a fixed-length subexpression, so it cannot appear *? + These quantifiers are only available for sequential view.

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.