Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expression.

Status
Not open for further replies.

DaSe

Programmer
Feb 14, 2008
149
GB
Hi guys , that's not really difficuly I guess but I'm just trying to get the hang of the Perl expressions.Thanks for any reply in advance.Here the question :

Why the output is "TRUE" from this code below since each letter on the right ( [col] ) must match exactly 4 times...?Since there is only "c" and one "l" in the [cool].

if ("cool" =~ m/[col]{4}/
{ print ("True") ; }

 
It's true because [col] is a "character class"

m/[col]{4}/ means "c" OR "o" OR "l" must be there 4 times.

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top