in reply to Ideas to improve this regexp?

Your regex does match the empty string, which it should not from your descriptions. So remove the |^$ part.

You can also write your regex as /\A(?>\s*)\D/, where (?>\s*) means grab all whitespaces and don't give them up for backtracking.

I don't know if you consider that more simple or elegant, though.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Ideas to improve this regexp?
by rovf (Priest) on Nov 03, 2009 at 14:17 UTC
    Your regex does match the empty string, which it should not from your descriptions.

    My mistake in wording the question. I've updated the post.

    I like your alternative suggestion too, but as you already suspected, it is not much simpler anyway.
    -- 
    Ronald Fischer <ynnor@mm.st>