I am new to regular expression and I am trying to form a regular expression for below scenarios having combination of letters and decimal number upto 2 precision:
GBP 23.44 -> Valid
23.44 -> Valid
23 -> Valid
23 GBP -> Valid
234.44 GBP -> Valid
234.44 -> Valid
23.334 GBP -> Invalid
234.443 GBP -> Invalid
234& GBP -> Invalid
Moreover no other characters should be allowed other than A-Z and a-z and Number with 2 precisions.
My attempt:
I tried ^[Aa-Zz][0-9]+(\\.[0-9]{1,2})?$
, but its not working as per the expression numbers always needed to be followed after characters like 234.44 GBP
is failing to match.
I am not able to form exact expression which satisfy all the scenarios. Please help.