Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'framework.': 0.07; 'subject:help': 0.07; 'python': 0.09; 'matched': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'dec': 0.15; 'complicated,': 0.16; 'subject:required': 0.16; 'then?': 0.16; 'wed,': 0.16; 'string': 0.17; 'wrote:': 0.17; '>>>': 0.18; 'wednesday,': 0.22; 'cc:2**0': 0.23; 'matching': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'replace': 0.27; 'spam,': 0.29; 'december': 0.32; "skip:' 20": 0.32; 'hi,': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'text.': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'subject:-': 0.40; 'help': 0.40; 'thomas': 0.62; 'more': 0.63; 'urgent': 0.66; 'subject: & ': 0.67; 'received:209.85.216.184': 0.84 Newsgroups: comp.lang.python Date: Wed, 19 Dec 2012 03:53:07 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=182.178.37.85; posting-account=gL3NJgoAAABqumi65WD0uvB0Xp0lRXiO References: User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 182.178.37.85 MIME-Version: 1.0 Subject: Re: Pattern-match & Replace - help required From: AT To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355917989 news.xs4all.nl 6973 [2001:888:2000:d::a6]:34518 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35104 On Wednesday, 19 December 2012 16:27:19 UTC+5, Thomas Bach wrote: > On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote: > > > Hi, > > > > > > I am new to python and web2py framework. Need urgent help to match a > > > pattern in an string and replace the matched text. > > > > > > > Well, what about str.replace then? > > > > >>> 'egg, ham, tomato'.replace('ham', 'spam, ham, spam') > > 'egg, spam, ham, spam, tomato' > > > > > > If the pattern you want to match is more complicated, have a look at > > the re module! > > > > Regards, > > Thomas. The pattern is '%s.enc_%s', and after matching this pattern want to change it to 'decrypt(%s.enc_%s)' Thanks