Hi ,
 
Thanks guys for your quick response.
 
I will try it out combinations and get back to you if i have issues.
 
 
 
Regards,
chandan.

--- On Thu, 15/7/10, Thomas Bätzler <t.baetz...@bringe.com> wrote:


From: Thomas Bätzler <t.baetz...@bringe.com>
Subject: AW: Query on Qunatifiers
To: "Beginners Perl" <beginners@perl.org>
Cc: "Chandan Kumar" <chandan_28...@yahoo.com>
Date: Thursday, 15 July, 2010, 7:22 AM


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