Alexander Lomia Alexander Lomia - 2 months ago 8x
PHP Question

Regex for validating alpha_dash and exactly one dot symbol

I want to validate names of uploaded files. For now, I have the following regex which matches only alphanumeric characters, dashes and underscores:


However, I need to also ensure, that the filename contains exactly one dot character. How should I modify this regex to achieve the desired result?


Pull the period out of your character class, like this: