I can't seem to make my regex work so i think I must be doing something wrong. If anyone could help me out that would be great.
here is my regex function
let validatePlate = (plate) => {
var re = /(^[A-Z]{2}[0-9]{2}\s?[A-Z]{3}$)|(^[A-Z][0-9]{1,3}[A-Z]{3}$)|(^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(^[0-9]{1,4}[A-Z]{1,2}$)|(^[0-9]{1,3}[A-Z]{1,3}$)|(^[A-Z]{1,2}[0-9]{1,4}$)|(^[A-Z]{1,3}[0-9]{1,3}$)|(^[A-Z]{1,3}[0-9]{1,4}$)|(^[0-9]{3}[DX]{1}[0-9]{3}$)/
return re.test(plate);
};
and I use it in textInput as follows:
<TextInput
onChange={validatePlate}
editable={true}
}}>
Hello
</TextInput>
It still allows special characters, etc.
FYI: The regex is for filtering UK numberplates.