Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: <5960761@gmail.com> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'string.': 0.05; 'string': 0.09; 'python': 0.11; '"|"': 0.16; '12:59': 0.16; 'backslashes': 0.16; 'notation': 0.16; 'operator.': 0.16; "skip:' 60": 0.16; 'skipping': 0.16; 'subject:Regular': 0.16; 'wrote:': 0.18; 'header :User-Agent:1': 0.23; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'too.': 0.31; 'pipe': 0.31; 'regular': 0.32; 'raw': 0.33; 'subject:the': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'hi,': 0.36; 'message-id:@gmail.com': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'unable': 0.39; 'expression': 0.60; 'containing': 0.69; 'default': 0.69; 'special': 0.74; 'skip:| 10': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=hNhEblJaqNouBjey9gW2vuvLLzP8Wb4w6mIU8KUJS8Q=; b=vIKH7kOTbZr2C9KYPFC7/qj0mxyoujGTgq+B+Ci70s9Aqt06OIgCJ597XJoTEgESfu 9wmOg0eVZrTJCchFoiFp8rhZtOle8YweyK1j/kVKi38OhR+8QHMNM1c9DdP8dcK/YRaQ a2NOrEOnsgMbY+w0HkbobRaYmzHD4wkBH3cLyb9+RbJKlrOmnBnDSOxDqVBqwT/5wGlG dLr1JVvpULstGQqiM9nbgn4xpBzcRfPvQmdACAlngnqE6Bx3JKMsz8Nw4azt7xdXyub4 PFoYhZBd9jQMl9Z9MduE4GqFPBGhS5hhiGztCypujpR0Eo7RDtCU6M/eLmIGkZu/qB4P BMbg== X-Received: by 10.194.157.226 with SMTP id wp2mr38980542wjb.58.1401190180882; Tue, 27 May 2014 04:29:40 -0700 (PDT) Date: Tue, 27 May 2014 14:29:38 +0300 From: Daniel <5960761@gmail.com> User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Regular Expression for the special character "|" pipe References: <9c8e58be-9619-44c7-8098-961a0134c422@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401190577 news.xs4all.nl 2890 [2001:888:2000:d::a6]:55831 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72112 What about skipping the re and try this: 'start=|ID=ter54rt543d|SID=ter54rt543d|end=|'.split('|')[1][3:] On 27.05.2014 14:09, Vlastimil Brom wrote: > 2014-05-27 12:59 GMT+02:00 Aman Kashyap : >> I would like to create a regular expression in which i can match the "|" special character too. >> >> e.g. >> >> start=|ID=ter54rt543d|SID=ter54rt543d|end=| >> >> I want to only |ID=ter54rt543d| from the above string but i am unable to write the pattern match containing "|" pipe too. >> >> By default python treat "|" as an OR operator. >> >> But in my case I want to use to as a part of search string. >> -- > Hi, > 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. > > hth, > vbr