I recently asked for help with a regular expression; I now know I did not ask for enough!
Can somebody please compose for me a regular expression that will extract all numbers from a string. There could be a single instance of a number, there could be multiple instances of numbers, there will be other text in the string and each of the numbers may or may not contain decimal points. Where decimal points are present, there is no fixed precision. Numbers may also contain thousand seperators (normally a comma).
Examples:
- “(123 items with 234 sub items)” – results: “123”, “234”
- “123 @ 234.56%” – results: “123”, “234.56”
- “(123 @ 234.56%)” – result: “123”, “234.56”
- “@ 123.45 %” – result: “123.45”
- “123 @ 4.56 p” – results: “123”, “4.56”
- “12,345.67 and 2345.67” – results: – “12,345.67”, “2345.67”
I will be using the .NET regular expression engine.
"[0-9][0-9,.]*"