Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31033
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: string contains and special characters |
| Date | 2012-10-09 15:50 +0100 |
| References | <a6a8b018-f7d1-43ae-bee8-a2f2028866f1@googlegroups.com> <5074336E.9050404@davea.name> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2004.1349794188.27098.python-list@python.org> (permalink) |
On 09/10/2012 15:23, Dave Angel wrote:
> On 10/09/2012 10:02 AM, loial wrote:
>> I am trying to match a string that containing the "<" and ">" characters, using the string contains function, but it never seems to find the lines containing the string
>>
>> e.g if mystring.contains("<TAG>") :
>>
>> Do I need to escape the characters...and if so how?
>>
>
> What language are you trying to use, and what version of that language?
> In all the Python versions I know of, that line would simply be a syntax
> error. There's no "contains" method in the str class, use the 'in' keyword.
I see you've already corrected youself :)
>
> if "<TAG>' in mystring:
>
> No need to escape any ASCII characters except backslash.
>
No need to escape anything if raw strings are used.
--
Cheers.
Mark Lawrence.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
string contains and special characters loial <jldunn2000@gmail.com> - 2012-10-09 07:02 -0700
Re: string contains and special characters Agon Hajdari <agonh@freenet.de> - 2012-10-09 16:10 +0200
Re: string contains and special characters loial <jldunn2000@gmail.com> - 2012-10-09 08:09 -0700
Re: string contains and special characters loial <jldunn2000@gmail.com> - 2012-10-09 08:09 -0700
Re: string contains and special characters Dave Angel <d@davea.name> - 2012-10-09 10:23 -0400
Re: string contains and special characters Jerry Hill <malaclypse2@gmail.com> - 2012-10-09 10:34 -0400
Re: string contains and special characters Dave Angel <d@davea.name> - 2012-10-09 10:34 -0400
Re: string contains and special characters Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-09 15:50 +0100
Re: string contains and special characters Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-09 16:59 +0200
csiph-web