Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72112
| Date | 2014-05-27 14:29 +0300 |
|---|---|
| From | Daniel <5960761@gmail.com> |
| Subject | Re: Regular Expression for the special character "|" pipe |
| References | <9c8e58be-9619-44c7-8098-961a0134c422@googlegroups.com> <CAHzaPEPqruhi57cK5BQt0roRRkqKOfgAdM5Yoe-stM+Ta5FB9w@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10369.1401190577.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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