http://www.perlmonks.org?node_id=592205


in reply to regexp question

Try replacing the space character in your match with "\s*". The '*' says to match a whitespace character 0 or more times.

Replies are listed 'Best First'.
Re^2: regexp question
by deibyz (Hermit) on Dec 29, 2006 at 11:46 UTC
    That would also match words of more than 20 chars "splited", making \s* = "".

    If I had to keep this limitation I would do:

    my @a = grep { /^.{1,20}$/ } split " ", $string