Conditional Splitting in Perl Conditional Splitting in Perl unix unix

Conditional Splitting in Perl


Try splitting on:

/(?<!\.)\s+/

This expression matches any space character that does not follow a period, without matching the period itself.


Without a split using a regex:

my @words = $sent =~ /(\S+\.\s+\S+|\S+)/g;