Why this regex assertion doesn't match?

感情迁移 提交于 2019-12-12 07:07:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!