I have the following regex
(^[a-zA-z]+([a-zA-Z\\s-]*)[a-zA-z]+$)
It disallow all special chars except ( ` ) the console key. Could someone expl
Do not use [A-z], use [a-zA-Z]:
^[a-zA-Z]+([a-zA-Z\s-]*)[a-zA-Z]+$
Otherwise, the [A-z] class will match some other non-letter symbols, too:
Here is a demo on regex101.com.
Just a note: [A-z] can sometimes be used to match all letters in POSIX-style regex when collation is set for a particular language.
[[ "ABCEDEF[]_abcdef" =~ ([A-z]+) ]] && echo "${BASH_REMATCH[1]}" on Cygwin with LC_COLLATE="en_US.UTF-8" yields ABCEDF.
If you set LC_COLLATE to C (on Cygwin, done with export), it will give the expected ABCEDEF[]_abcdef.