Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inconsistent Results
#8
This regular expression extracts decimal numbers in any format. Positive, negative, with or without commas, integers or with decimal point, with or without positive or negative exponent.

Code:
Copy      Help
CURRENCY a b="100000"
[color=blue]str [/color]c="AMOUNT (100,000.00)"

[color=blue]str [/color]rx="[+-]? *\d+(,\d+)*(\.\d+)?([Ee][+-]\d+)?" [color=green];;regexp to extract numbers[/color]

[color=blue]if[/color]([color=blue]findrx[/color](c rx 0 0 c)<0) [color=blue]out [/color]"number not found"; [color=blue]ret[/color]
[color=blue]out [/color]c
a=c

[color=blue]mes iif[/color](a<=b "ok" "not ok")


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)