Many programming languages have a function for that to do that for you...
In Perl, it's called quotemeta (qw, qq and family, too), in Python and Ruby it's .escape... and there's always \Q ... \E to use...
I'm sure others have similar methods/functions.
Re:Stop avoiding regular expressions damn it
by GhotiFish on Sunday May 12, 2013 @10:26AM
(#5694350)
I agree with that criticism, so do other people, that's why the implementation of Regular Expressions are anything but regular.
That always makes me giggle.
It's not an interface, it's a language. Most (all?) languages have collisions between in-band and out-of-band information and ways to "escape" them.
An interface that e.g. makes me 'escape' half of my input because its designers think their special use of characters must take precedence over all user input is a bad interface.