Chandan Kumar <chandan_28...@yahoo.com> asked:
> I have query over quantifiers.
> 
> Could you please explain the combination of operators Question mark
> (?),dot(.),star(*),plus(+).
> 
> Say this is my string:
> 
> $_ = " thiiiiis is my first pattern ,quite confused with quantifiers"
> 
> ex: (thi.*?) or (thi.+?) etc
> 
> I know what each operator does if used seperately,but combination of
> these operators are confusing.

You should really read the provided documentation - Uri posted about that to 
the list just a short while ago ;-)

Please note that "." is not a quantifier. "?", "+" and "*" are.

In RE, a "." by itself is the atom that matches any one character.

The quantifiers mean:

"?" 0 or 1 occurences of the previous expression.
"+" 1 or more occurrences of the previous expression (greedy match).
"*" 0 or more occurrences of the previous expression (greedy match).
"*?" 0 or more occurrences of the previous expression (parsimonious match).
"+?" 1 or more occurrences of the previous expression (parsimonious match).

The difference between greedy and parsimonious matching is that in a greedy 
match, the longest possible match will be tried first whereas in a parsimonious 
match, the shortest match will be tried first.

HTH,
Thomas

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to