Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'ascii': 0.07; 'class,': 0.07; 'escape': 0.07; 'function,': 0.07; 'used.': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:characters': 0.09; 'subject:string': 0.09; 'language': 0.14; 'keyword.': 0.16; 'language?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'string': 0.17; 'wrote:': 0.17; 'versions': 0.20; 'trying': 0.21; 'error.': 0.21; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'raw': 0.27; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; 'str': 0.29; 'from:addr:yahoo.co.uk': 0.32; 'to:addr:python- list': 0.33; 'version': 0.34; 'received:org': 0.36; 'except': 0.36; 'but': 0.36; 'characters': 0.36; 'method': 0.36; 'anything': 0.36; 'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; "you've": 0.61; 'containing': 0.61; 'angel': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: string contains and special characters Date: Tue, 09 Oct 2012 15:50:26 +0100 References: <5074336E.9050404@davea.name> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-146-6-157.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: <5074336E.9050404@davea.name> X-Antivirus: avast! (VPS 121009-0, 09/10/2012), 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349794188 news.xs4all.nl 6858 [2001:888:2000:d::a6]:40361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31033 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("") : >> >> 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 "' in mystring: > > No need to escape any ASCII characters except backslash. > No need to escape anything if raw strings are used. -- Cheers. Mark Lawrence.