I would like to check if a given String
is in a amount format. A few examples for a better understanding:
Should return true
:
2x
31x
3x abcd
Should return false
:
2x3
3xabc
asdf3x
So in general: it has to start with a number (0-9), can be more digits. Right after the number a "x"/"X" should follow and after the "x"/"X" should be the end or a white space.
I am struggling to get this done.. This is what I tried:
func isAmountFormat() -> Bool {
return self.matches("[0-9]+[X,x]")
}
Can anyone help me out here?