Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.04; 'instance,': 0.05; 'defines': 0.07; 'rules.': 0.07; 'will,': 0.07; 'syntax.': 0.09; 'am,': 0.12; 'received:209.85.214.174': 0.13; '10:45': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'needed?': 0.16; 'sign,': 0.16; 'wrote:': 0.18; 'trying': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'literal': 0.23; 'pieces': 0.23; 'string': 0.24; 'message- id:@mail.gmail.com': 0.28; '27,': 0.29; 'expressions': 0.29; 'fairly': 0.30; 'down,': 0.30; 'strings,': 0.30; 'translate': 0.31; 'anyone': 0.31; 'received:209.85.214': 0.32; 'tue,': 0.32; "can't": 0.32; 'that,': 0.33; 'there': 0.33; 'to:addr:python- list': 0.34; 'probably': 0.34; 'regular': 0.35; 'received:google.com': 0.37; 'seeing': 0.38; 'received:209.85': 0.38; 'help': 0.39; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'might': 0.40; 'once': 0.60; 'more': 0.61; '2011': 0.61; 'your': 0.61; 'ever': 0.65; 'order,': 0.73; 'letters,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=eTT5KcT+KK/y0oNm1TSDLYMmcQQPnr26uPLsT0n9sag=; b=TuxdDp04q2MfwcRU4k8eYj3+uKm5BTJBGqOqMATSOkgGfpYu5DU5S5f1aHz0zOfQzU PtV7plVXQ4bMqR+JRhjPIoPhjLXcxpkO1qc9Xb0RVbZuHayQ8fqnrP7Xr+fctz2PbDtm AaEDwr/12Plsru8Aoz/EqJ21n1jvnOx4itIm4= MIME-Version: 1.0 In-Reply-To: <495b6fe6-704a-42fc-b10b-484218ad8409@b20g2000pro.googlegroups.com> References: <495b6fe6-704a-42fc-b10b-484218ad8409@b20g2000pro.googlegroups.com> Date: Tue, 27 Dec 2011 11:00:08 +1100 Subject: Re: Regular expressions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324944010 news.xs4all.nl 6928 [2001:888:2000:d::a6]:34519 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17994 On Tue, Dec 27, 2011 at 10:45 AM, mauriceling@acm.org wrote: > Hi > > I am trying to change to . > > Can anyone help me with the regular expressions needed? A regular expression defines a string based on rules. Without seeing a lot more strings, we can't know what possibilities there are for each part of the string. You probably know your data better than we ever will, even eyeballing the entire set of strings; just write down, in order, what the pieces ought to be - for instance, the first token might be a literal @ sign, followed by three upper-case letters, then a hyphen, then any number of alphanumerics followed by a colon, etc. Once you have that, it's fairly straightforward to translate that into regex syntax. ChrisA