Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31021 > unrolled thread
| Started by | loial <jldunn2000@gmail.com> |
|---|---|
| First post | 2012-10-09 07:02 -0700 |
| Last post | 2012-10-09 16:59 +0200 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.python
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
| From | loial <jldunn2000@gmail.com> |
|---|---|
| Date | 2012-10-09 07:02 -0700 |
| Subject | string contains and special characters |
| Message-ID | <a6a8b018-f7d1-43ae-bee8-a2f2028866f1@googlegroups.com> |
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?
[toc] | [next] | [standalone]
| From | Agon Hajdari <agonh@freenet.de> |
|---|---|
| Date | 2012-10-09 16:10 +0200 |
| Message-ID | <mailman.1997.1349792372.27098.python-list@python.org> |
| In reply to | #31021 |
On 10/09/2012 04:02 PM, 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?
>
if '<TAG>' in yourstring:
# your code
--
Agon Hajdari
[toc] | [prev] | [next] | [standalone]
| From | loial <jldunn2000@gmail.com> |
|---|---|
| Date | 2012-10-09 08:09 -0700 |
| Message-ID | <309cb8b0-ff38-4e2d-bb58-87d1d787fbed@googlegroups.com> |
| In reply to | #31026 |
On Tuesday, 9 October 2012 15:19:33 UTC+1, Agon Hajdari wrote:
> On 10/09/2012 04:02 PM, 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? > if '<TAG>' in yourstring: # your code -- Agon Hajdari
That worked...thanks
[toc] | [prev] | [next] | [standalone]
| From | loial <jldunn2000@gmail.com> |
|---|---|
| Date | 2012-10-09 08:09 -0700 |
| Message-ID | <mailman.2005.1349795375.27098.python-list@python.org> |
| In reply to | #31026 |
On Tuesday, 9 October 2012 15:19:33 UTC+1, Agon Hajdari wrote:
> On 10/09/2012 04:02 PM, 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? > if '<TAG>' in yourstring: # your code -- Agon Hajdari
That worked...thanks
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-10-09 10:23 -0400 |
| Message-ID | <mailman.1999.1349792644.27098.python-list@python.org> |
| In reply to | #31021 |
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.
if "<TAG>' in mystring:
No need to escape any ASCII characters except backslash.
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Jerry Hill <malaclypse2@gmail.com> |
|---|---|
| Date | 2012-10-09 10:34 -0400 |
| Message-ID | <mailman.2002.1349793260.27098.python-list@python.org> |
| In reply to | #31021 |
On Tue, Oct 9, 2012 at 10:02 AM, loial <jldunn2000@gmail.com> 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?
Strings don't have a contains() method. Assuming that mystring is
actually a string, you should be getting a very specific error,
telling you exactly what's wrong with your code (something like
AttributeError: 'str' object has no attribute 'contains').
If that isn't what you're seeing, you'll need to provide the full and
complete text of the error you are getting, and preferably enough of
your code that we can reproduce the issue and help you solve it.
--
Jerry
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-10-09 10:34 -0400 |
| Message-ID | <mailman.2003.1349793304.27098.python-list@python.org> |
| In reply to | #31021 |
On 10/09/2012 10:23 AM, 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
Sorry, I should have said "Attribute" error.
> error. There's no "contains" method in the str class, use the 'in' keyword.
>
> if "<TAG>' in mystring:
>
> No need to escape any ASCII characters except backslash.
>
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-10-09 15:50 +0100 |
| Message-ID | <mailman.2004.1349794188.27098.python-list@python.org> |
| In reply to | #31021 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Date | 2012-10-09 16:59 +0200 |
| Message-ID | <1nqdk9-iov.ln1@satorlaser.homedns.org> |
| In reply to | #31021 |
Am 09.10.2012 16:02, schrieb loial:
> 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>") :
I can't locate a 'contains' function anywhere, what type is 'mystring'?
> Do I need to escape the characters...and if so how?
Maybe. Please provide some example code that unexpectedly fails.
Uli
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web