Answer the question
In order to leave comments, you need to log in
Why doesn't assertion work in regular expression?
#(<img.+>\s*)(?!</a>)#Uu
In this regular expression, you need to select the img tag, after which the tag does not follow </a>
. It finds all img tags, that is, it does not work correctly.
If you look for the img tag after which there is </a>
, then such a similar regular expression works:#(<img.+>\s*)(?=</a>)#Uu
Answer the question
In order to leave comments, you need to log in
#(<img.+>\s*)(?!</a>)#Uu
In this regular expression, you need to select the img tag, after which the tag does not follow</a>
. It finds all img tags, that is, it does not work correctly.
\s*
and you have it with a quantifier *
- zero or many , and it turns out that in this case, "zero" repetitions of the "previous" ( \s
) work and therefore, as it were, looks forward img
tags after which there are none </a>
, then you should write something like this, Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question