5

I need regular expression for ID number, it's 9 numbers and the first number must be 4 or 9 or 8.

can some one help ?

2
  • What have you tried and what is not working? (If this is homework please tag it as such.) Commented Apr 12, 2011 at 19:11
  • No it's not Homework, it's for my graduation project. Commented Apr 12, 2011 at 19:18

1 Answer 1

16

You can use the following regex:

^[489][0-9]{8}$
Sign up to request clarification or add additional context in comments.

1 Comment

Regarding your comment on @Jellicle's answer, the anchors are not mandatory in some engines depending on how you inkove it. In Java, for example, if you were using the standard String.matches() or Matcher.matches() you don't need them, but if you were doing Matcher.find() you would. That answer was deleted so I'm leaving it here as it's also relevant to this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.