Pattern-match & Replace - help required
AT
matifayaz at gmail.com
Wed Dec 19 08:41:47 EST 2012
More information about the Python-list mailing list
Wed Dec 19 08:41:47 EST 2012
- Previous message (by thread): Pattern-match & Replace - help required
- Next message (by thread): Pattern-match & Replace - help required
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wednesday, 19 December 2012 18:16:18 UTC+5, Peter Otten wrote: > AT wrote: > > > > > I am new to python and web2py framework. Need urgent help to match a > > > pattern in an string and replace the matched text. > > > > > > I've this string (basically an sql statement): > > > stmnt = 'SELECT taxpayer.id, > > > taxpayer.enc_name, > > > taxpayer.age, > > > taxpayer.occupation > > > FROM taxpayer WHERE (taxpayer.id IS NOT NULL);' > > > > > > The requirement is to replace it with this one: > > > r_stmnt = 'SELECT taxpayer.id, > > > decrypt(taxpayer.enc_name), > > > taxpayer.age, > > > taxpayer.occupation > > > FROM taxpayer WHERE (taxpayer.id IS NOT NULL);' > > > > > > Can somebody please help? > > > > > The pattern is '%s.enc_%s', and after matching this pattern want to change > > > it to 'decrypt(%s.enc_%s)' > > > > after = re.compile(r"(\w+[.]enc_\w+)").sub(r"decrypt(\1)", before) Thanks a million Can you recommend a good online book/tutorial on regular expr. in python? Regards
- Previous message (by thread): Pattern-match & Replace - help required
- Next message (by thread): Pattern-match & Replace - help required
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list