Reputation: 1
Total regex newbie here and I have been all over the place to try and find an answer. I need to add exactly 1 space followed by a string of letter characters (min 3 max 30) I have the following but it will accept more than 1 space which is the problem:
^[:blank:][A-z]{3,30}$
Any help with this would be great
Upvotes: 0
Views: 51
Reputation: 626903
[A-z]
will also capture [, \, ], ^, _, `
.
Use this regex to allow exactly 1 space in the beginning and then 3 to 30 English letters:
^[[:blank:]][a-zA-Z]{3,30}$
See demo.
Upvotes: 2
Reputation: 91430
To be unicode compatible:
^\p{Zs}\p{L}{3,30}$
Where \p{Zs}
stands for a space character
and \p{L}
stands for a letter.
Upvotes: 0