Alexander Lomia Alexander Lomia - 8 months ago 45
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: