RegEx headaches :)

Associate
Joined
27 Jun 2006
Posts
1,473
Hey all.

I have some text along the lines of:

"There are 12,345,678 people in the country of.......(0.3% of which blah blah blah)", and what I am trying to do is grab the number of people in the country only.

The number can be any where from 0 to <insert biggest number you can think of :)) but will contain commas in the right places.

I am still trying to get my head round regex, and to be honest not very successfully so any help or pointers appreciated on a Sunday morning!!

Cheers


EDIT: (\d+)(,\d+)* but that also matches the second lot of numbers (0.3 in the example above) - getting there :)
 
Last edited:
Soldato
Joined
18 Oct 2002
Posts
6,751
Location
Cambridge
How about ' ([\d,]+) ' (space at start and end)? If the second number is always followed by a percentage I would expect that to work.

arty
 
Back
Top Bottom