Word break problem: Difference between revisions

Content deleted Content added
SqrtNegInf (talk | contribs)
m →‎{{header|Perl}}: updated output, simplified regex
SqrtNegInf (talk | contribs)
m →‎{{header|Perl}}: oops, missing
Line 510:
my @matches;
my $one_of = join '|', @dictionary;
@matches = $word =~ /^ ($one_of) ($one_of)? ($one_of)? ($one_of)? $/x; # sub-optimal: limited number of matches
return join(' ', grep {$_} @matches) || "(not possible)";
}</lang>