> From: Steve Massey [mailto:[EMAIL PROTECTED] > Sent: 23 October 2003 11:33 > > #! /usr/bin/perl -w > > $test = "BRIGHTON,,,,,,,,,,,,,,,, (Firm),,,,,,,,,,,,,,,,,,,,,,,,,,,,"; > > > print "$test\n"; > $test =~ s/,*/,/; > $test =~ s/,*$/,/g; > > print "$test\n";
It looks like the +/* issue has been discussed. The other option you could use would be ,{2,} which matches 2 or more ,s in a row. The other thing that I notices is that you are using the g option on the wrong substitution. It matches repeatedly within the string. There will only ever be one set of commas at the end of the string, but there may be multiple sets within the string. A single substitution of $test =~ s/,+/,/g; will replace the string at the end as well as any that show up in mid-string. The second substitution can then be changed if you don't want a trailing comma, to $test =~ s/,$//; /\/\ark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]