Sunday, 15 September 2013

Regex to get text After anchor tag C# -



Regex to get text After anchor tag C# -

i have c# regex follows:

regex r = new regex(@"(?<value1>.*?)<a.*?href=(""|')(?<href>.*?)(""|').*?>(?<value2>.*?)</a>(?<value3>.*?)");

i can text value1, href, value2 perfect. however, value3 "".

what missing text comes after anchor closing tag().

you wouldn't homecoming null value if utilize parser instead, since parsing html regular look not best way approach this. prepare issue, remove non-greedy quantifier end of look making greedy (matching amount possible).

(?<value3>.*?) ^ remove non-greedy quantifier

and create greedy:

(?<value3>.*)

see live demo

c# regex anchor

No comments:

Post a Comment