Regex Remove Images with style tag from Html

后端 未结 5 1198
遥遥无期
遥遥无期 2020-12-11 08:57

I am new to Regex, however I decided it was the easiest route to what I needed to do. Basically I have a string (in PHP) which contains a whole load of HTML code... I want

5条回答
  •  借酒劲吻你
    2020-12-11 09:06

    Because doesn't allow any other elements inside it, this is possible; but in general, regexp is a thoroughly bad tool for parsing a recursively defined language like HTML.

    Anyway, the problem you're probably hitting is that the closing > is being matched by one of the .* expressions, and there happens to be a later > on the line to match your explicit > .

    If you replace all your .* by [^>]* that will prevent that. (They probably don't all need to be replaced, but you might as well).

提交回复
热议问题