in reply to Regex for splitting a string on a semicolon (conditionally)

> my $part = $text =~ s/\;(?=(\s[A-Z]{1}[a-z]+,\s([a-zA-z]\.-?)+\,))/\n/g;

> ...but this returns in the number of matching semicolons ("2" in this case). This has been driving me absolutely nuts--any help is appreciated!

$text =~ s/\;(?=(\s[A-Z]{1}[a-z]+,\s([a-zA-z]\.-?)+\,))/\n/g;

does the substitution in $text but returns their number in scalar context.

drop $part and do my @parts = split("\n",$text);

Cheers Rolf

PS: Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Regex for splitting a string on a semicolon (conditionally)
by grouse (Initiate) on Feb 12, 2015 at 09:16 UTC
    Thank you so much. I feel somewhat embarassed for missing that one! Making the change makes everything work as intended, thanks!