I want to write a JavaScript input key validator. I want to use regular expressions for this purpose. When user presses a key – input text field is checked that his value satisfy some regular expression, and if it isn’t then user input is rejected.
Is it possible to catch a match when regular expression matches only part of expression?
Just for better understanding of question:
Regular expression: ([0-9]{3})([0-9Xx]+)
"" matches "0" matches "01" matches "01c" not matches "014" matches "0149" matches "0149x" matches "0149xD" not matches "0149xDX" not matches "0149xX" matches
and so on…
^([0-9]{0,2}|[0-9]{3}[0-9Xx]*)$