Sorry if I'm duping someone else, but I came in late on this post. It is always useful to remember that tr will count the number of times a character matched.
So, my $count = $str =~ tr/://; will return the number of colons there are in $str. Therefore, you could see if $count was == 6. HTH, Tanton ----- Original Message ----- From: "Mark Anderson" <[EMAIL PROTECTED]> To: "Stuart Clark" <[EMAIL PROTECTED]> Cc: "Beginners@Perl. Org" <[EMAIL PROTECTED]> Sent: Tuesday, February 12, 2002 3:59 PM Subject: RE: Troubles with reg exp > If you really want a regexp: > > if (/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*$/) { > > This looks for ^ (the beginning of the line), [^:]* (0 or more characters > that are not ':'), : (a colon), and ultimately $ the end of the line. > > /\/\ark > > -----Original Message----- > From: Stuart Clark [mailto:[EMAIL PROTECTED]] > Sent: Monday, February 11, 2002 7:32 PM > To: perllist > Subject: Troubles with reg exp > > > Hi All, > I'm having trouble with this regular expression > I have data file with colon separated delimiters > The data below has 6 colon delimiters > I want to check to make sure that none of the lines of data has more or less > than 6 colons in it (EG: Lets say David enters his phone number as > 9876:4342) > The rest of my file works ok, its just matching the 6 colons. > > # File > David:smith:21 lake drv::98764342:: > John:Jones:44 ratfink st:west mouseville:8432321:: > ## > > > I have tried this > > if ($_ =~ m/:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:/) { > > and > > if ($_ = ~ m/:{6}/) { > > Regards > Stuart Clark > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]