Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get the regex-pattern for the following sequence of numbers:

X.XXX.XXX-X 

Every X is one number.

How can I do that? I don't want to use *, because I need exactly the number of numbers.

share|improve this question
up vote 2 down vote accepted

Use braces to specify the number of occurrences:

\d{1}\.\d{3}\.\d{3}-\d{1}

{3} will match the previous token exactly 3 times. You can also specify a range like {1,5} which will match the previous token between 1 and 5 times. This is a greedy match and will match as many characters as possible.

share|improve this answer
    
Thank you. It worked – Christian Woerz Nov 6 '13 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .