-1

Can someone help me out here? I need a regex that will match the following pattern:

10-(any 5 digits except 73480)-(any 4 digits)

Examples valid: 10-12345-1234 invalid: 10-73480-1234

Thanks

Paolo Stefan
  • 10,112
  • 5
  • 45
  • 64
Kenny
  • 2,150
  • 2
  • 22
  • 30
  • 1
    What was wrong with the accepted answer to [your previous question](http://stackoverflow.com/q/12628885/78845)? – johnsyweb Jan 16 '13 at 17:10
  • where is the language tag! – Anirudha Jan 16 '13 at 17:10
  • possible duplicate of [A comprehensive regex for phone number validation](http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation) – Andy Lester Jan 16 '13 at 17:11
  • This is a solved problem. People have already written, tested and debugged code that handles this already. Whenever you have a programming problem that others have probably had to deal with, then look for existing code that does it for you. – Andy Lester Jan 16 '13 at 17:12
  • Johnsyweb - It was not allowing codes that should have worked. I decided to ask for help rewriting it to be more precise to the actual problem. I think I didn't spec it correctly the first time. – Kenny Jan 16 '13 at 19:18
  • Andy - I doubt that someone has already solved that exact problem, but if they have it would be a coincidence, because we are dealing with an internal code, not a phone number. – Kenny Jan 16 '13 at 19:19
  • And finally, I'd like to comment on the "closed as too localized". I thought that this community existed as a resource to get help with programming problems. Why should I have to generalize my question just to get help? If there is a better place to ask such questions, then please forgive my ignorance and feel free to point me there. I'm going to read the FAQ now. – Kenny Jan 16 '13 at 19:20
  • This is from the FAQ: Stack Overflow is for professional and enthusiast programmers, people who write code because they love it. We feel the best Stack Overflow questions have a bit of source code in them, but if your question generally covers … a specific programming problem a software algorithm software tools commonly used by programmers practical, answerable problems that are unique to the programming profession … then you’re in the right place to ask your question! The very first one says "a specific programming problem", which is what I had. – Kenny Jan 16 '13 at 19:22

1 Answers1

2

You should use negative lookahead to check for any occurance of 10-73480 before matching..

^(?!10-73480)10-\d{5}-\d{4}$

Try it here

Anirudha
  • 32,393
  • 7
  • 68
  • 89