PC Review


Reply
Thread Tools Rate Thread

C# Regex Help - should be an easy one

 
 
Oren Liebermann
Guest
Posts: n/a
 
      28th Apr 2004
I'm parsing through the HTML for an nba box score looking to pull out
the officials' names, but the regex expression I'm using is pulling
out the officials and all the code after the officials, which I don't
need.

So here's my regex:
"Officials:.*/td>"

and here's the HTML I'm getting back:
"Officials:#24 Mike Callahan, #9 Derrick Stafford,
#54&nbsp;Derrick&nbsp;Collins</td><td
align=\"right\">Attendance:&nbsp;14796</td></tr></table><!-- End Game
Info table --><!-- START Visitor player Stats team table --><table
width.......

This goes on for pages and pages.

I only want from "Officials" to the first "/td>" and I'm pretty sure
it's the * in my regex that's messing it up, but I'm not sure how to
fix it. Any help would be greatly appreciated!!
 
Reply With Quote
 
 
 
 
Brian Davis
Guest
Posts: n/a
 
      28th Apr 2004

Use the lazy quantifier *? instead of greedy quantifier *

"Officials:.*?/td>"

This will stop at the first occurrence of /td> rather than the last.

Brian Davis
http://www.knowdotnet.com


"Oren Liebermann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm parsing through the HTML for an nba box score looking to pull out
> the officials' names, but the regex expression I'm using is pulling
> out the officials and all the code after the officials, which I don't
> need.
>
> So here's my regex:
> "Officials:.*/td>"
>
> and here's the HTML I'm getting back:
> "Officials:#24&nbsp;Mike&nbsp;Callahan, #9&nbsp;Derrick&nbsp;Stafford,
> #54&nbsp;Derrick&nbsp;Collins</td><td
> align=\"right\">Attendance:&nbsp;14796</td></tr></table><!-- End Game
> Info table --><!-- START Visitor player Stats team table --><table
> width.......
>
> This goes on for pages and pages.
>
> I only want from "Officials" to the first "/td>" and I'm pretty sure
> it's the * in my regex that's messing it up, but I'm not sure how to
> fix it. Any help would be greatly appreciated!!



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex: different options on different sections of the Regex? Ethan Strauss Microsoft C# .NET 4 11th Jul 2008 03:54 PM
Is there a good way to turn regex patterns into properly-escaped c# regex patterns? sherifffruitfly Microsoft C# .NET 3 11th Feb 2007 09:56 AM
Regex question (easy?) sb Microsoft Dot NET 5 23rd Sep 2006 02:10 PM
Easy RegEx question Alan Silver Microsoft ASP .NET 4 20th Jul 2005 09:04 PM
RegEx - easy question =?Utf-8?B?YmF5bG9y?= Microsoft Dot NET 1 23rd Jun 2005 10:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:29 PM.