Re: [Tutor] Simple regex replacement match (converting from Perl)

2009-09-04 Thread Jerry Hill
On Fri, Sep 4, 2009 at 1:34 PM, GoodPotatoes wrote: > I simply want to remark out all non-word characters read from a line. > > Line: > Q*bert says "#...@!$%  " > > in Perl > #match each non-word character, add "\" before it, globally. > > $_=s/(\W)/\\$1/g; > > output: > Q\*bert\ says\ \"\...@\!\$\

[Tutor] Simple regex replacement match (converting from Perl)

2009-09-04 Thread GoodPotatoes
I simply want to remark out all non-word characters read from a line. Line: Q*bert says "#...@!$% " in Perl #match each non-word character, add "\" before it, globally. $_=s/(\W)/\\$1/g; output: Q\*bert\ says\ \"\...@\!\$\%\ \ \" #perfect! Is there something simple like this in python? I