Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'string': 0.09; 'escape': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'backslashes': 0.16; 'notation': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Regular': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header :User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'about.': 0.31; 'pipe': 0.31; 'regular': 0.32; 'raw': 0.33; 'subject:the': 0.34; 'thanks': 0.36; 'saves': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'expression': 0.60; 'more': 0.64; 'talking': 0.65; 'response.': 0.68; 'skip:r 40': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Wolfgang Maier Subject: Re: Regular Expression for the special character "|" pipe Date: Tue, 27 May 2014 13:55:58 +0200 References: <9c8e58be-9619-44c7-8098-961a0134c422@googlegroups.com> <3cc77455-39ed-4403-a46c-5dd8e640a483@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: bio-192-52-35-237.mobile.uni-freiburg.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: <3cc77455-39ed-4403-a46c-5dd8e640a483@googlegroups.com> 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: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401191774 news.xs4all.nl 2841 [2001:888:2000:d::a6]:35648 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72114 On 27.05.2014 13:39, Aman Kashyap wrote: >> On 27.05.2014 14:09, Vlastimil Brom wrote: >> >>> you can just escpape the pipe with backlash like any other metacharacter: >>> >>> r"start=\|ID=ter54rt543d" >>> >>> be sure to use the raw string notation r"...", or you can double all >> >>> backslashes in the string. >> > Thanks for the response. > > I got the answer finally. > > This is the regular expression to be used:\\|ID=[a-z]*[0-9]*[a-z]*[0-9]*[a-z]*\\| > or, and more readable: r'\|ID=[a-z]*[0-9]*[a-z]*[0-9]*[a-z]*\|' This is what Vlastimil was talking about. It saves you from having to escape the backslashes.