Help for Regex Expression

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

Hi,
I have the expression
"<font[^>]+>""([^""]*)""</font>[^?]+\?AUTHOR_ID=[0-9]+"">([^<]*)</a>"
Any body can tell me what is the meaning of that expression and what is the output of the expression.
Regards,
Muhammad Jamil Nawaz
 
J

jongalloway

It would match the following text:
<font size="2">""hello""</font><a
href="view.aspx?AUTHOR_ID=56789"">click here</a>

In this case, the following text could be anything, and I've just
provided samples:
size="2"
hello
view.aspx
click here

This regex captures two strings - the text inside the font tags and the
text inside the link. In this case, there would be two captured
strings:
hello
click here

This looks wrong to me - the double quotes ("") should probably be
single quotes ("):
<font[^>]+>"([^"]*)"</font>[^?]+\?AUTHOR_ID=[0-9]+">([^<]*)</a>

One trick to figure out a difficult Regex is to use Regulator's
analyzer output (http://regex.osherove.com/). The output in this case
is as follows:

<font
Any character not in ">"
+ (one or more times)
Capture
Any character not in """"
* (zero or more times)
End Capture
""</font>
Any character not in "?"
+ (one or more times)
?AUTHOR_ID=
Any character in "0-9"
+ (one or more times)
"">
Capture
Any character not in "<"
* (zero or more times)
End Capture
</a>

- Jon
http://weblogs.asp.net/jgalloway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top