Update: the above code produces exactly what the OP asked for, but it could be that 22222\:2222 is a typo and that this "2" string doesn't include a backslash. If so then just split on [:\n] or something like that.#!/usr/bin/perl -w use strict; my $string = '111111111:22222\:2222:333333333:4444444'; $string =~ s/\\:/:/; #translate \: to just : #the "trick" and its all over now... chomp ($string); #don't worry about trailing \n my @strings = split (/:/,$string); foreach my $line (@strings) { print "$line\n"; } __END__ prints: 111111111 22222 2222 333333333 4444444
In reply to Re: Easy Split
by Marshall
in thread Easy Split
by ropey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |