Alexander Lomia Alexander Lomia - 5 months ago 27
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: