Home All Groups Group Topic Archive Search About
Author
28 Sep 2006 7:24 PM
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

Author
30 Sep 2006 8:03 PM
Göran_Andersson
Why not simply "<img[^>]>"?

GS wrote:
Show quoteHide quote
> 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
>
>
Author
1 Oct 2006 3:11 AM
GS
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

Show quoteHide quote
"Göran Andersson" <gu***@guffa.com> wrote in message
news:e5DKUuM5GHA.3840@TK2MSFTNGP06.phx.gbl...
> 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
> >
> >
Author
1 Oct 2006 4:32 PM
Göran_Andersson
There is never ever an ending tag for the img tag, and even if there
were, your pattern doesn't handle that.

GS wrote:
Show quoteHide quote
> 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" <gu***@guffa.com> wrote in message
> news:e5DKUuM5GHA.3840@TK2MSFTNGP06.phx.gbl...
>> 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
>>>
>>>
>
>
Author
2 Oct 2006 5:50 AM
GS
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>))",


Show quoteHide quote
"Göran Andersson" <gu***@guffa.com> wrote in message
news:OqhvAdX5GHA.1248@TK2MSFTNGP03.phx.gbl...
> There is never ever an ending tag for the img tag, and even if there
> were, your pattern doesn't handle that.
>
> GS wrote:
> > 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" <gu***@guffa.com> wrote in message
> > news:e5DKUuM5GHA.3840@TK2MSFTNGP06.phx.gbl...
> >> 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
> >>>
> >>>
> >
> >
Author
4 Oct 2006 12:36 AM
Göran_Andersson
GS wrote:
> 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.

Show quoteHide quote
>
> "Göran Andersson" <gu***@guffa.com> wrote in message
> news:OqhvAdX5GHA.1248@TK2MSFTNGP03.phx.gbl...
>> There is never ever an ending tag for the img tag, and even if there
>> were, your pattern doesn't handle that.
>>
>> GS wrote:
>>> 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" <gu***@guffa.com> wrote in message
>>> news:e5DKUuM5GHA.3840@TK2MSFTNGP06.phx.gbl...
>>>> 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
>>>>>
>>>>>
>>>
>
>