问题
I'm trying to just preg content between html tags, I'm trying this simple assertion pattern and I don't understand why it doesn't match this string.
<a href=http://url.com title="link">this is a ling</a>
(?<=<a.*>)([ \w]*)(?=<.*\/a>)
Debuggex Demo
回答1:
Lookbehinds on debuggex (PCRE, Javascript and Python) cannot be of variable width, meaning that you can use (?<=<a>)
which has a fixed width (3 characters) but not something that can vary in length (?<=<a.*>)
(can have 3 characters, or 4, or 5, etc).
The regex simply is not valid but debuggex tells you that there is no match.
来源:https://stackoverflow.com/questions/22821644/why-this-regex-assertion-doesnt-match