I'm trying to have some restriction on a text input.
I want it to accept only :
- alphanumerical characters (a-z A-Z 0-9)
- 3 special characters (comma, dash, single quotation mark) : , - '
- A few accented characters : à â ç è é ê î ô ù û
- spaces
So I'm declaring a validator with a regex pattern to the input like this :
this.form.addControl('adresseLine2', new FormControl('', Validators.pattern(PatternValidatorEnum.ADRESS_CONTENT)));
And the ADRESS_CONTENT
regex is as follows :
ADRESS_CONTENT = '^[A-Za-z0-9\',\-àâçèéêîôùû ]*$'
It seems to work fine, but, the input stays valid when I have uppercase accented characters like : É
I want it to accept only lowercase accented characters (àâçèéêîôùû
)
And according to https://regex101.com/r/6vyA8H/1 : dsdséàê ké
should be a valid input but dsdséàê kÉ
should not.
However, both are considered valid on my input.
Also, my input accepts characters such as .
, ;
, /
when it shouldn't according to the regex.
What am I missing ? Also, there might be some cases I forgot in my regex.