user3491049
user3491049

Reputation: 13

Why this regex assertion doesn't match?

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

Upvotes: 1

Views: 542

Answers (1)

Jerry
Jerry

Reputation: 71578

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.

Upvotes: 4

Related Questions