I want to find number with don't proceed with £ character. Say I have a string:
"Gross Domestic Product in 2012 was £127 billion"
I want to return 2012 only.
I ve tried [^$][0-9]* but this only ignores $ character. Tried to match the whole word which starts and ends with number \b[0-9]*\b but \b applies only to [0-9a-zA-Z]
Any more suggestions?
One option which works (as tested using http://gskinner.com/RegExr) is:
(?<![£0-9])[0-9]+
This uses negative lookbehind to exclude £. The additional exclusion of 0-9 is to prevent it finding "27" in the above in addition to the "2012".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With