Groups | Blog | Home
all groups > c# > june 2003 >

c# : Regex Question



Jon Lynch
6/26/2003 10:01:38 AM

The .* term is gobbling up the whole string. Use .*? (non-greedy gobble) or
just [^<]*.

There is a tradeoff, as always. .*? is slightly more expensive at
run-time, but it's a little clearer.

Jon

[quoted text, click to view]

Arild Bakken
6/26/2003 3:09:36 PM
Try the following expression:

<A[^>]*>.*?</A>

Notice the question mark to indicate a "lazy" matching so that it stops at
the first occurence of </A> and not at the last on the line.


Arild

[quoted text, click to view]

NotYetaNurd
6/26/2003 5:11:47 PM
I have a text like this
<a href=aaaa>something </a><a href=aaaa>something </a><a href=aaaa>something
</a><a href=aaaa>something </a><a href=aaaa>something </a>
i have to extract each "<a href=aaaa>something </a> "out i did something
like this
<A[^>]*>.*</A>

but it returns the whole string rather than individual "<a
href=aaaa>something </a>"

Where am i going wrong.....


NotYetaNurd
6/27/2003 1:10:51 PM
Thanks You ...
[quoted text, click to view]

AddThis Social Bookmark Button