There's a fun little idiom using tr/// to count the number of
occurances of a character in a string:

    perl -le '$str = "a,b,c,d,e"; $count = ($str =~ tr/,/,/); print "$count"'

will output "4", the number of commas in "a,b,c,d,e".

--Kester
  
> Jeff Williams wrote, on Tue 12/14/2004 11:23
> : I wrote a RegEx to let me know if a line of text has exactly 36 commas in
> it (the comma is the separator) and I came up with this. I don't think it
> is quite right. I could use a little pointing in the right direction. Any
> thoughts?
> 
> 
> : $lines[0] =~/^(.*?,){36}.*?$/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to