Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
string contains and special characters
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
loial  
View profile  
 More options Oct 9 2012, 10:02 am
Newsgroups: comp.lang.python
From: loial <jldunn2...@gmail.com>
Date: Tue, 9 Oct 2012 07:02:22 -0700 (PDT)
Local: Tues, Oct 9 2012 10:02 am
Subject: string contains and special characters
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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agon Hajdari  
View profile  
 More options Oct 9 2012, 10:19 am
Newsgroups: comp.lang.python
From: Agon Hajdari <ag...@freenet.de>
Date: Tue, 09 Oct 2012 16:10:40 +0200
Local: Tues, Oct 9 2012 10:10 am
Subject: Re: string contains and special characters
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Angel  
View profile  
 More options Oct 9 2012, 10:24 am
Newsgroups: comp.lang.python
From: Dave Angel <d...@davea.name>
Date: Tue, 09 Oct 2012 10:23:42 -0400
Local: Tues, Oct 9 2012 10:23 am
Subject: Re: string contains and special characters
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jerry Hill  
View profile  
 More options Oct 9 2012, 10:34 am
Newsgroups: comp.lang.python
From: Jerry Hill <malaclyp...@gmail.com>
Date: Tue, 9 Oct 2012 10:34:17 -0400
Local: Tues, Oct 9 2012 10:34 am
Subject: Re: string contains and special characters

On Tue, Oct 9, 2012 at 10:02 AM, loial <jldunn2...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Angel  
View profile  
 More options Oct 9 2012, 10:35 am
Newsgroups: comp.lang.python
From: Dave Angel <d...@davea.name>
Date: Tue, 09 Oct 2012 10:34:30 -0400
Local: Tues, Oct 9 2012 10:34 am
Subject: Re: string contains and special characters
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Oct 9 2012, 10:49 am
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Tue, 09 Oct 2012 15:50:26 +0100
Local: Tues, Oct 9 2012 10:50 am
Subject: Re: string contains and special characters
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
loial  
View profile  
 More options Oct 9 2012, 11:09 am
Newsgroups: comp.lang.python
From: loial <jldunn2...@gmail.com>
Date: Tue, 9 Oct 2012 08:09:30 -0700 (PDT)
Local: Tues, Oct 9 2012 11:09 am
Subject: Re: string contains and special characters

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
loial  
View profile  
 More options Oct 9 2012, 11:10 am
Newsgroups: comp.lang.python
From: loial <jldunn2...@gmail.com>
Date: Tue, 9 Oct 2012 08:09:30 -0700 (PDT)
Local: Tues, Oct 9 2012 11:09 am
Subject: Re: string contains and special characters

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ulrich Eckhardt  
View profile  
 More options Oct 9 2012, 11:15 am
Newsgroups: comp.lang.python
From: Ulrich Eckhardt <ulrich.eckha...@dominolaser.com>
Date: Tue, 09 Oct 2012 16:59:13 +0200
Local: Tues, Oct 9 2012 10:59 am
Subject: Re: string contains and special characters
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »