Regular Expressions: An Introduction
Published: January 12, 2004
User Rating: 8.9 (282 votes)
Quantifiers
Quantifiers are those characters in the pattern, that specify how many characters to match. Or they "quantify" the the characters to match.
- * Quantifier: Match 0 or more characters (match any number of characters)
- ? Quantifier: Match 0 or 1 characters
- {min,max} Quantifier: Match (between min and max) characters
- {specific} Quantifier: Match (specific) number of characters
Taking a few examples
Taking a few realtime matching cases of the last examples
You can see in the last match, result is TRUE. This is becasue, we didn't specify where to match the pattern, so the pattern is matched in anywhere in the subject. And if you don't specify the location, it doesn't matter where the match is found.
However, if were to take the above example, with a slight change, and specify the location, interesting results come out. Lets see:
As you can see, in the last match, result is False. To understand it, read the explaination carefully. At the end of the subject match "a", followed by 2, 3 or 4 characters. In simple terms we can say it again as "match a string which has third, fourth or fifth character from the end is a"
About
Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.

Monitored by Site24x7
Uptime