Chandru
Chandru

Reputation: 109

Combine regex validation for pdf and file name should not have a '+' or '%' sign

How to validate a filename with a extension '.pdf' and it should not have a '+' or '%' sign in its name? The regex to check for the 'pdf' extension is /(\.|\/)(pdf)$/i,. How to combine these validations?

Upvotes: 1

Views: 1612

Answers (1)

RomanPerekhrest
RomanPerekhrest

Reputation: 92854

Use the following regex pattern:

^[^+]+\.pdf$
  • ^ - start of the string

  • [^+]+ - one or many characters except +

https://regex101.com/r/MZhqSL/4

Upvotes: 2

Related Questions