regex question

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

what is a good regex expression for remove html <img ....> tag?
I tried
"<img [/:.a-z =0-9\""_;&]*\->", RegexOptions.IgnoreCase)
but it is not quite working

thank you for your time
 
thanks for replying. However I found this worked better for me

myregex = New Regex("<img .*?(>|(/>|(</img>))",
RegexOptions.IgnoreCase Or
RegexOptions.ExplicitCapture)
It does not gobble up other tags fooling the <img .....> on the same line.
it also supposed to take care of xml also

Credit is due to Dave Sexton for helping arriving at the above expression

Göran Andersson said:
Why not simply "<img[^>]>"?
what is a good regex expression for remove html <img ....> tag?
I tried
"<img [/:.a-z =0-9\""_;&]*\->", RegexOptions.IgnoreCase)
but it is not quite working

thank you for your time
 
There is never ever an ending tag for the img tag, and even if there
were, your pattern doesn't handle that.
thanks for replying. However I found this worked better for me

myregex = New Regex("<img .*?(>|(/>|(</img>))",
RegexOptions.IgnoreCase Or
RegexOptions.ExplicitCapture)
It does not gobble up other tags fooling the <img .....> on the same line.
it also supposed to take care of xml also

Credit is due to Dave Sexton for helping arriving at the above expression

Göran Andersson said:
Why not simply "<img[^>]>"?
what is a good regex expression for remove html <img ....> tag?
I tried
"<img [/:.a-z =0-9\""_;&]*\->", RegexOptions.IgnoreCase)
but it is not quite working

thank you for your time
 
So far I have not seem ending tag for <img ..> at least for html.

although I think I have sees some comments of XML <img tags and <object tags
both have ending tags of sorts

I did made mistake in thr regex for the ending tag by leaving out one right
paranthesis

myregex = New Regex("<img .*?(>|(/>)|(</img>))",


Göran Andersson said:
There is never ever an ending tag for the img tag, and even if there
were, your pattern doesn't handle that.
thanks for replying. However I found this worked better for me

myregex = New Regex("<img .*?(>|(/>|(</img>))",
RegexOptions.IgnoreCase Or
RegexOptions.ExplicitCapture)
It does not gobble up other tags fooling the <img .....> on the same line.
it also supposed to take care of xml also

Credit is due to Dave Sexton for helping arriving at the above expression

Göran Andersson said:
Why not simply "<img[^>]>"?

GS wrote:
what is a good regex expression for remove html <img ....> tag?
I tried
"<img [/:.a-z =0-9\""_;&]*\->", RegexOptions.IgnoreCase)
but it is not quite working

thank you for your time
 
GS said:
So far I have not seem ending tag for <img ..> at least for html.

although I think I have sees some comments of XML <img tags and <object tags
both have ending tags of sorts

Yes, but XML is a completely different thing. There the tag name "img"
has no special meaning at all.
I did made mistake in thr regex for the ending tag by leaving out one right
paranthesis

myregex = New Regex("<img .*?(>|(/>)|(</img>))",

It still doesn't handle the ending tag, if there ever was one. As the
starting tag ends with ">" that will be caught instead of the ending tag.
Göran Andersson said:
There is never ever an ending tag for the img tag, and even if there
were, your pattern doesn't handle that.
thanks for replying. However I found this worked better for me

myregex = New Regex("<img .*?(>|(/>|(</img>))",
RegexOptions.IgnoreCase Or
RegexOptions.ExplicitCapture)
It does not gobble up other tags fooling the <img .....> on the same line.
it also supposed to take care of xml also

Credit is due to Dave Sexton for helping arriving at the above expression
Why not simply "<img[^>]>"?

GS wrote:
what is a good regex expression for remove html <img ....> tag?
I tried
"<img [/:.a-z =0-9\""_;&]*\->", RegexOptions.IgnoreCase)
but it is not quite working

thank you for your time
 
Back
Top