Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72116

Re: Regular Expression for the special character "|" pipe

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'string.': 0.05; 'string': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language.': 0.14; '"|"': 0.16; '12:59': 0.16; 'backslashes': 0.16; 'notation': 0.16; 'operator.': 0.16; 'paragraphs,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; "skip:' 60": 0.16; 'skipping': 0.16; 'spacing': 0.16; 'subject:Regular': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thanks.': 0.20; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'url:moin': 0.24; '---': 0.24; 'daniel': 0.26; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'character': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'too.': 0.31; 'url:wiki': 0.31; '>>>>': 0.31; 'pipe': 0.31; 'regular': 0.32; 'url:python': 0.33; 'raw': 0.33; 'subject:the': 0.34; 'but': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'list': 0.37; 'e.g.': 0.38; 'to:addr :python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'unable': 0.39; 'mailing': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'read': 0.60; 'expression': 0.60; 'free': 0.61; 'viruses': 0.61; 'protection': 0.63; 'our': 0.64; 'response.': 0.68; 'antivirus': 0.68; 'containing': 0.69; 'default': 0.69; 'special': 0.74; 'received:2': 0.84; 'skip:| 10': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Regular Expression for the special character "|" pipe
Date Tue, 27 May 2014 14:06:18 +0100
References <9c8e58be-9619-44c7-8098-961a0134c422@googlegroups.com> <CAHzaPEPqruhi57cK5BQt0roRRkqKOfgAdM5Yoe-stM+Ta5FB9w@mail.gmail.com> <mailman.10369.1401190577.18130.python-list@python.org> <3cc77455-39ed-4403-a46c-5dd8e640a483@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-196-77.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <3cc77455-39ed-4403-a46c-5dd8e640a483@googlegroups.com>
X-Antivirus avast! (VPS 140527-0, 27/05/2014), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10371.1401195996.18130.python-list@python.org> (permalink)
Lines 82
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401195996 news.xs4all.nl 2901 [2001:888:2000:d::a6]:52907
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72116

Show key headers only | View raw


On 27/05/2014 12:39, Aman Kashyap wrote:
> On Tuesday, 27 May 2014 16:59:38 UTC+5:30, Daniel  wrote:
>> 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 <amankashyap1223@gmail.com>:
>>
>>>> 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
>
> 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]*\\|
>

I'm pleased to see that you have answers.  In return would you please 
use the mailing list 
https://mail.python.org/mailman/listinfo/python-list or read and action 
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us 
seeing double line spacing and single line paragraphs, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Regular Expression for the special character "|" pipe Aman Kashyap <amankashyap1223@gmail.com> - 2014-05-27 03:59 -0700
  Re: Regular Expression for the special character "|" pipe Vlastimil Brom <vlastimil.brom@gmail.com> - 2014-05-27 13:09 +0200
    Re: Regular Expression for the special character "|" pipe Aman Kashyap <amankashyap1223@gmail.com> - 2014-05-27 04:20 -0700
  Re: Regular Expression for the special character "|" pipe Daniel <5960761@gmail.com> - 2014-05-27 14:29 +0300
    Re: Regular Expression for the special character "|" pipe Aman Kashyap <amankashyap1223@gmail.com> - 2014-05-27 04:39 -0700
      Re: Regular Expression for the special character "|" pipe Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-05-27 13:55 +0200
        Re: Regular Expression for the special character "|" pipe Roy Smith <roy@panix.com> - 2014-05-27 08:35 -0400
      Re: Regular Expression for the special character "|" pipe Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-27 14:06 +0100

csiph-web