- Angular - How to allow special characters with Validator.pattern?

Hi all,
I want allow special characters into my field “title” but not " ’ ; + ; = ; - ", only characters with accents like " é ; à ; è ; ê ; ï ", …
My code actually (it work)
.ts :

this.annonce_form = new FormGroup({
      title: new FormControl('', Validators.compose([
        Validators.maxLength(25),
        Validators.minLength(5),
        Validators.required,
        Validators.pattern('^(?=.*[a-zA-Z])[a-zA-Z0-9]+$'), // <-- Allow letters and numbers only
      ])),
    })

Ty ! :smiley:

Simply implement a better Regex through your pattern …

https://regexr.com to learn and train :slight_smile:

1 Like

Regarding to your needs, here is the regex that suits the best : ([^+-’=]+)