Forum Moderators: coopster
All I simply need is a preg_replace expression for removing all <img> tags from a string.
What I have at the moment is:
@<img[^>]>@si
From what I understand, that should simply match...
<img **ANYTHING-EXCEPT-'>'** >
..but it does not seem to work. Where am I going wrong?
[^>]
will indeed match any character that is not a ">". However, it will only match one occurrence of this character. The following strings would be matched by your regular expression.
<img >
<imga>
<img4>
<img#>
What you want is something like this
@<img[^>]+>@si
The "+" indicates "match the preceding character/character class one or more times". With that in place, you should be able to catch strings like
<img src="foo" height="blah" />