Wednesday, January 28, 2009

Repetition

Like you have learned using the plus and star for repeating, it is also possible to specify the repetition of groups or character classes more exactly.

{20} repeat 20 times
{20,} repeat 20 times or more
{,20} repeat 0 to 20 times
{20,30} repeat at least 20 times and not more than 30 times.

\w{2,3}

Yes we can do it together!

Use the step over button in the RegExCoach to see what happens.

Another example would be to check the number of digits.

\d{6}

123456

This will match any number with exactly 6 digits.

You can also use the repetition after a group () .

([acnwe]){2,3}

Yes we can do it together, can we?

The character class must match 2 or 3 times.

No comments:

Post a Comment