• 0

C# regex question


Question

I need a regex expression to isolate the numric values from a webpage in the format:

"java script:register_bids(10242783);"

where I want the number extrected into a int[], but no matter what I do I don't get any matches.

Regex rBid = new Regex(@"javascript[:]register[_]bids[(](\d*)[);]");
byte[] b;
b = wc.DownloadData(URI.Text);
string downloaded = Encoding.ASCII.GetString(b);
MatchCollection mBid = rBid.Matches(downloaded);
int[] iBid = new int[mBid.Count];
Response.Write(mBid.Count);//just to test
	for(int i=0;i< mBid.Count; i++)
	{
  Response.Write( mBid[i].Groups[1].Value );
  //Response.Write(iBid[i]);
	}

This is for my photoalbum. I have some 1800 pictures and to get the storage for the pictures I use a photoservice called eurofoto(www.eurofoto.no) but I dislike their photoalbum so I wrote my own from scractch based only on them doing the storage and resizing(thumbnailing).

I have before used a very primitive search system that required that I needed to clean up the html, but now I wanted to utelize regex as it's more robust.

I want it to go through the html code and extract the pictureIds, into a int array.

Any help is appreciated.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Only thing I can see right off the bat is that your regular expression is faulty. Try this:

Regex rBid = new Regex(@"javascript:register_bids\((\d+)\);");

Hope that helps,

bwx

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.