I try make regular expression for one letter Z and 12 digits.
event.target.value = event.target.value.replace(/[^Z{1}+(\d{12})]/, '');
It is necessary for me that in the input field it was possible to enter one letter Z and then 12 digits only.
Please help me.
The regexp is
^
matches the beginning of the stringZ
matches the initialZ
. There's no need for{1}
since patterns always match exactly one time unless quantified.\d{12}
matches exactly 12 digits$
matches the end of the string