Alexander Lomia Alexander Lomia - 1 year ago 116
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download