Help with regex search-and-replace (Perl to Python)

Steve Holden steve at holdenweb.com
Sun Feb 7 08:25:28 EST 2010


@ Rocteur CC wrote:
> 
> On 07 Feb 2010, at 10:03, Shashwat Anand wrote:
> 
>> Here is one simple solution :
>> >>> intext = """Lorem [ipsum] dolor sit amet, consectetur adipisicing
>> elit, sed do eiusmod tempor  incididunt ut [labore] et [dolore] magna
>> aliqua."""
>>
>> >>> intext.replace('[', '{').replace(']',
>> '}')                                      
>> 'Lorem {ipsum} dolor sit amet, consectetur adipisicing elit, sed do
>> eiusmod tempor  incididunt ut {labore} et {dolore} magna aliqua.'
>>
>> /Some people, when confronted with a problem, think "I know, I’ll use
>> regular expressions." Now they have two problems./ — Jamie Zawinski
>> <ttp://jwz.livejournal.com> in comp.lang.emacs.
> 
> That is because regular expressions are what we learned in programming
> the shell from sed to awk and ksh and zsh and of course Perl and we've
> read the two books by Jeffrey and much much more!!!
> 
> How do we rethink and relearn how we do things and should we ?
> 
> What is the solution ?
> 
A rigorous focus on programming simplicity.

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list