First post! :)

I have some problem with finding a number in a specific row in a HTML document i'm fetching. I dont really know much of Regexp, but i guess thats how i will do it?

The code i'm using

StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream(), Encoding.ASCII);
                int countLines = 0;

                        //Find: 		<td valign="top" align="right" >124379</td>
                      //sr.ReadLine(); //That one should hold the number.

I want to parse out 124379 from:
<td valign="top" align="right" >124379</td>

That number can differ (not always 6 chars). Anyone knows how to do it?


Finding examples of the regular expression library in C# is easy, so I'll leave that to you. The regular expression you want might be something like this:


What this does is look for any number with one or more digits (+\d), surrounded by > on the left side and < on the right side with optional whitespace between. It'll pick up any HTML element value that's just a number, so if you want to match just table data elements, you can be more specific:


Now the regular expression matches an opening tag of "<td" followed by any number of attributes, the value string as before, and also the closing tag of "/td>.

This article has been dead for over six months. Start a new discussion instead.