Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression which allows alphabets, dashes(-) and dot(.)

I'm trying to write a regex which allows alphabets, dot . and dashes - (for validation)

But couldn't find a valid regex which would do so, please help!

Thanks in advance

like image 743
Rajdeep Singh Avatar asked Sep 02 '25 09:09

Rajdeep Singh


1 Answers

I think this will work for you

^[a-zA-Z-.]*$

any lowercase letter of the alphabet, any uppercase letter of the alphabet, dash as a group in any combination appearing 1 or many times

like image 52
Sabyasachi Ghosh Avatar answered Sep 04 '25 00:09

Sabyasachi Ghosh