in reply to Re^2: Regex for splitting a string on a semicolon (conditionally) (use Text::CSV;)
in thread Regex for splitting a string on a semicolon (conditionally)
sub breakup { my $filename = $_[0]; my $text = $_[1]; my @stuff = split /;\s?/, $text; my @parts ; while( @stuff ){ if( $stuff[0] =~ m{ ^ \w+ : \s \w+ $ }xms ){ $parts[-1] .= ";".$stuff[0]; } else { push @parts, $stuff[0]; } shift @stuff; } return \@parts; }
|
|---|