Reputation: 157
Need a regular expression to get the amount (892.33
) from the below text
Property Tax Allotment 3.76% 892.33 USD
Condition - It should not consider numbers with trailing % sign
Am trying with the below pattern
\\s?[0-9\\.,]{2,20}(?!\\%)\\s?
but getting 3.76
without % sign
Upvotes: 0
Views: 72
Reputation: 44200
How about this:
\d+\.\d\d(?= USD)
One or more digits \d+
followed by a literal dot \.
and two more digits \d\d
, with a positive lookahead for " USD" (?= USD)
It would need to be modified slightly if the fractional component of the price is optional.
Upvotes: 1