The Personal Web Pages of Chris X. EdwardsRegular Expression Tutorial |
The predefined quantifiers are sufficient for almost all regular
expression work, but in rare cases, even more quantifier control is
needed. Most regular expression engines provide a system to explicitly
define acceptable quantities. This syntax looks like this:
{min,max}
The "min" is a number that represents the minimum number of the
modified character to accept as a match. The "max" specifies the
maximum number of these characters allowed.
Matches "10", "100", and "1000", but neither "1" nor "10000"..
If there is no maximum or minimum limit, you can leave that out
allowing for a maximum limit quantifier and a minimum limit
quantifier.
{min,}
/10{3,}/
Matches "1000", "10000", "100000000", etc, but not "100".
{,max}
/10{,3}/
Matches "1", "10", "100", and "1000", but only partially matches
"10000", "1000000", etc. In this case, the match finds the first 1000
and ignores the rest.
Here's an example:
This will match "1,000", "10,000", "100,000", but not "1000,000".
If you've made it this far, good job! You must be really interested in regular expressions and you are finding my tutorial helpful. Unfortunately, this is the last lesson that I've prepared. There are lots of other neat things one can do with regular expressions:
Previous | Home | Next |
This page was created with only free, open-source, publicly licensed software. This page was designed to be viewed with any browser on any system. | ||
Chris X. Edwards ~ December 2003 |