I need to develop a validation pattern for catching any kind from:
pdf/csv/xlsx
select any separate word is simple:
(pdf|csv|xlsx).
However, I need to check that any combination with them separated by slash is fine as well.
For example, correct flow:
JavaScript
x
pdf/csv/xlsx
pdf
pdf/csv
csv/xlsx
xlsx
pdf/xlsx
Incorrect:
JavaScript
test
incorrect
doc
Advertisement
Answer
You may use this regex:
JavaScript
^(?:pdf|csv|xlsx?)(?:/(?:pdf|csv|xlsx?))*$