in reply to OptiPerls Pattern Replace (Regexpses for one Line)

what is a good RegExp for matching "anything to the end of the line"

/.*/ should do, as a dot matches anything that's not a newline. However, I'm trying to get rid of the habit, and try to learn myself to use /[^\n]*/ instead. This makes it easier to slap /s on your regex if you want dot to really match everything. And in Perl6, a dot will match everything anyway. If only Perl5 would recognize \N.

Replies are listed 'Best First'.
Re^2: OptiPerls Pattern Replace (Regexpses for one Line)
by Ben Win Lue (Friar) on Mar 02, 2005 at 10:45 UTC
    Thanks a lot!

    The /[^\n]*/ worked!
    I always thought that the backslash would lose its metacharacter behaviour in the brackets, so I didn't get the idea.

    The /.*/ did not work since I don't have a /s switch.