in reply to Regex: not the trailing whitespace

Just rely on greedy and non-greedy matching to eat up all the spaces where appropriate. Don't need any special new features, or even any additional boundary conditions:
my ($prefix, $content) = $line =~ / ^ \s* ([*#]+:?) \s* (.*?) \s* $ /x

Replies are listed 'Best First'.
Re^2: Regex: not the trailing whitespace
by John M. Dlugosz (Monsignor) on Apr 23, 2011 at 06:51 UTC
    I see. I don't remember exactly what I was thinking, but I suppose using a \S helps it optimize. OTOH, it might make it harder for the engine to understand. I should try some benchmarks with and without.