I am trying to build a regex to tell if a string is a valid file extension. It could be any extentions.
hello        no
.hello       Yes
..hello      No
hello.world  No
.hello.world No
.hello world No
I have tried ^\. and ^\.[\.] but can't get what i am looking for. This seems like it should be simple.
^\.[^.]+$
This means start with . and then anything other than dot (.)
You can also use this one if you want to have only aplhanumeric.:
^\.[a-zA-Z0-9]+$
Try this regex:
^\.[\w]+$
Matches a string starting with a ".", followed by one or more "word" character(s), until the end of the string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With