Need regex: find img tags in a string
Posted on 2007-08-11
I have a generated HTML string where I want to strip out all HTML tags except some special ones, so I am looking for a regular expression that can help me.
So my current idea is:
1) use a string replace to make (example) <img .../> tags to [img.../]
2) use a function like stripHTML to get rid of all HTML tags
3) convert the [img.../] back into <img.../>
So I need a query that finds <img...> and <img ... /> (with and without an "/" at the end).
And the same query for [img...]. The second one needs, as far as I know, some escapes, this is why I am not sure if it can be done easily.