I need to validate a string to check if the first two characters in a string are numbers.
I tried using in numeric but still had the issue that I did not want to check the whole string only the first two characters..
I need to validate a string to check if the first two characters in a string are numbers.
I tried using in numeric but still had the issue that I did not want to check the whole string only the first two characters..
2
Answers
This can be done using a Regular Expression
You can simply get the first two characters of the string on their own, and validate that:
demo: https://3v4l.org/C33ui.
Or you could use a Regular Expression, as per robotiaga’s answer