Title: RegEx help
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}.*?$/
Presumably you also want the fields, eventually. I'd use
 
@fields = split(/,/, $lines[0]);
 
and then you can simply check
 
if (@fields == 37)
{
}
 
(36 commas implies 37 fields). That way you already have the @fields array when you want them later.
 
Presumably the magic number 37 is a constant defined at the top of your script?
 
Good luck,
 
Joe
 

==============================================================
          Joseph P. Discenza, Sr. Programmer/Analyst
               mailto:[EMAIL PROTECTED]
 
          Carleton Inc.   http://www.carletoninc.com
          574.243.6040 ext. 300    fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to