I want to make a function for checking valid username but I’m confused what regular expression I need for this check?
username can have [a-zA-Z0-9-_.]
but username must start with letter like that -> [a-zA-Z]
username end character may not be a special character just letter or number
username can have unlimited dot or dash or underline, but not sequentially (they must be separated by letters or numbers)
for example this is valid username :
----------
e.r.m.y.a
ermya2
erm.y-a.2
erric.nelson
eric_nelson
eric-nelson
e-r-i-c_n-e.s.o-n
--------------
and invalid username is :
2ermya
erm..ya
er__mya
er--mya
er-_ya
er._-ya
er.-ya
ermya_
ermya.
ermya-
erm.-_ya
or much much more
I think
^[a-zA-Z]([._-]?[a-zA-Z0-9]+)*$might do the trick.
now it’s work