-2

I tried many pattern examples but none worked so far. I want to use a regex pattern that only allows English characters with no spaces and no special characters in flutter.

RegExp('[a-zA-Z]');

This is what I used before, but it allows spaces and other characters.

Also after using

r'/^[a-zA-Z]+$/'

The string entered in the username always returns false with spaces and special characters and without. I'm not looking for an answer in JavaScript also the other question doesn't have the answer I'm looking for.

  • 1
    Does this answer your question? [Restrict Special Character Input Flutter](https://stackoverflow.com/questions/50442372/restrict-special-character-input-flutter) – Ruchit Feb 08 '23 at 13:02

1 Answers1

-2

Here's a regular expression pattern to match only letters from the alphabet (both uppercase and lowercase):

/^[a-zA-Z]+$/

This pattern will match one or more characters that are in the range a-z or A-Z. The ^ and $ symbols indicate the start and end of the string, respectively, ensuring that only letters are present and no additional characters (such as spaces or numbers) are allowed.

Abhishek
  • 1
  • 1