Reputation: 366
I want to combine these regex's so I can have the right result, my point is the regex should use ( or ) so if the number was "(45.29 SAR ) or ( 4,523.88 SAR)"
here is the two regex that i've used :
\b\d+\.\d+\p{Zs}+SAR\b
\b\d+\,\d+\.\d+\p{Zs}+SAR\b
Thank you.
Upvotes: 0
Views: 67
Reputation: 626826
You may use a *
-quantified group of a comma followed with 3 digits:
\b\d{1,3}(?:,\d{3})*\.\d+\p{Zs}+SAR\b
See the regex demo
Explanation:
\b
- leading word boundary\d{1,3}
- 1 to 3 digits(?:,\d{3})*
- 0 or more groups of a comma followed with 3 digits\.
- aliteral comma\d+
- 1+ digits\p{Zs}+
- 1+ horizontal whitespaceSAR\b
- whole word SAR
Upvotes: 1