Regular Expressions match exactly 7 or 9 digits

Viewed 56518

My reg ex skills are almost zero and I am trying to match a field to have exactly 7 or 9 numbers (not between 7 or 9 so no 8 numbers is not valid).

I have tried (don't laugh)

/^([0-9]{7} | [0-9]{9})

and

/^([0-9]{7 | 9})

if someone could help and explain the answer that would be much appreciated.

I assume (maybe incorrectly) that is does not matter what (programming) language I am using

Thanks

6 Answers
Related