Hi!

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;

                while(!sr.EndOfStream())
                {
                        //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?

Thanks
/m

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:

">\s*\d+\s*<"

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:

"<td.*>\s*\d+\s*</td>"

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>.

Thx alot Narue, i think i can manage from here =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.