remove image tags in string

  • Thread starter Thread starter Smokey Grindel
  • Start date Start date
S

Smokey Grindel

I have a HTML string that I want to remove all the <IMG ....... > tags
from... any regex's out there for this? I basically just want to remove all
the images from the HTML.. thanks!
 
I have a HTML string that I want to remove all the <IMG ....... > tags
from... any regex's out there for this? I basically just want to remove all
the images from the HTML.. thanks!

I think the Regex pattern "<img\s.*?/>" should find all occurrences if
you use the SingleLine regex option. I briefly tested it in Expresso
with the following sample text - it seems to match everything it's
supposed to:

//////// Sample Text //////////

<html>
<head>
<title>Hello World</title>
</head>
<body>
<strong>Hello World</strong>
<img src="../someImage.PNG" alt="" />
<p>If you see the image(s) above or below I've screwed up my regex</
p>
<iMg src="../someOtherImage.PNG" alt="" />
<table>
<tr>
<td><IMG src="../yetAnotherImage.PNG" alt="" /></td>
<td><imgs src="../notAnImage.PNG" alt="Don't Select Me" /></td>
<td><img
src="../oneMoreImage.PNG"
alt=""
/>
</td>
</tr>
</table>
</body>
</html>

//////// End Sample Text //////////

Let me know how it works!

Thanks,

Seth Rowe
 
didn't work on the code I have... looks like they formatted it as IMG not
img... non-valid XHTML... had to add the ignore case flags to the
regex...then it worked.. thanks!
 
didn't work on the code I have... looks like they formatted it as IMG not
img... non-valid XHTML... had to add the ignore case flags to the
regex...then it worked.. thanks!

Sorry - I forgot to mention I had Ignore Case set in Expresso. I
should have noticed that since I even added tags with various
capitalizations to test - oh well, you get what you pay for.

:-)

Thanks,

Seth Rowe
 
rowe_newsgroups said:
I think the Regex pattern "<img\s.*?/>" should find all occurrences if
you use the SingleLine regex option.

This would work in most cases, but if 'SHORTTAG YES' is used, then it will
fail. Note that HTML is an SGML application and not XML!
 
Back
Top