in reply to Re^2: Simple Regex drives me insane
in thread Simple Regex drives me insane

It already does do that.

Specifically, it always matches, setting $1 to foo if #\w+ is found at the start of the string, and setting $1 to undef otherwise.

Replies are listed 'Best First'.
Re^4: Simple Regex drives me insane
by ikegami (Patriarch) on Mar 30, 2024 at 17:47 UTC

    That said, I believe it has other problems.

    It doesn't set $1 to foo when matching against bli #foo bla.

    It doesn't set $1 to the empty string when matching against bli bla. However, it does set it to undef, which might be close enough.