- #1
- 2,140
- 2,716
I was helping one of my classmates to set up the Ubuntu app on Windows 10 so that he can do Bash programming. While setting the username, he was getting an error due to bad regex, and that prompted me to look up the regex for username on Linux. This regex is stored in
As far as I understand, this pattern wants the username to begin with a lower case letter. Then there can be zero or more characters, chosen from hyphen, lower case letters, digits, and underscore. At the end, the dollar sign is escaped, so there has to be a literal
regex101.com says that my interpretation is correct. In fact,
However, my username is
Am I wrong somewhere in understanding the regex?
/etc/adduser.conf
file. The regex is as follows: ^[a-z][-a-z0-9_]*\$
As far as I understand, this pattern wants the username to begin with a lower case letter. Then there can be zero or more characters, chosen from hyphen, lower case letters, digits, and underscore. At the end, the dollar sign is escaped, so there has to be a literal
$
sign at the end.regex101.com says that my interpretation is correct. In fact,
user-name
does not match the regex, but user-name$
matches.However, my username is
wrichik-basu
, i.e., no $
-sign at the end. While setting up the Ubuntu app for my classmate, no dollar sign was required either.Am I wrong somewhere in understanding the regex?