Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Regular expressions Date: Wed, 4 Nov 2015 03:20:04 +1100 Lines: 15 Message-ID: References: <662g3blobme52hfoududj27err185v2npm@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de +c4bqdQ8MVihgRzEpH3j2AOUxNLVDSVNtTaxpKNv7bhA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'string.': 0.04; 'mrab': 0.05; 'cc:addr:python-list': 0.09; 'wed,': 0.15; "'*'": 0.16; '(so,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Regular': 0.16; 'subject:expressions': 0.16; 'wrote:': 0.16; 'string': 0.17; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'trying': 0.22; 'am,': 0.23; 'represents': 0.23; 'header:In-Reply- To:1': 0.24; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.29; 'character.': 0.29; 'methods.': 0.29; 'comments': 0.30; 'case,': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'express': 0.35; 'but': 0.36; 'received:209.85': 0.36; "wasn't": 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:209': 0.38; 'end': 0.39; 'sure': 0.39; 'yes': 0.62; 'ending': 0.63; 'answered,': 0.84; 'chrisa': 0.84; 'practicing': 0.84; 'seymore4head': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=AMQuCGVbWCQRqpTQ4dRr3C5x1Iriy4btfTvn0r91XaU=; b=sRskWk71QaKCurKSSmNRrUbcStwSjryB6IJ4XslLEvvELBYHfR97swHHEADPnVddyC QjA2clPYNVu5za8S327dFY/PKr+BgQU0yozBUty/+HVmikTMtYCA7PfsgA0PIyRTuHCw Ds27svKAoIyJLi6rDdD/b+emitfn2l9AkO0z8ySKhnM/TJrkZvNV5+yN4RSfXsKZ9Kfy KaIe/SMFeG3FTmS8t/NabiieQbdu32AT0ArBEE+SFNseoSwC676uoIpIeXmiYL1H6va+ q08bUxha8u2VSb007YuQgil2FcobcKg5ByadTslI0PDGRv+ABL7RlanKtSm1u2uQz53o x+ow== X-Received: by 10.107.137.167 with SMTP id t39mr26763849ioi.19.1446567604712; Tue, 03 Nov 2015 08:20:04 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98171 On Wed, Nov 4, 2015 at 3:10 AM, Seymore4Head wrote: > Yes I knew that -1 represents the end character. It is not a question > of trying to accomplish anything. I was just practicing with regex > and wasn't sure how to express a * since it was one of the > instructions. In that case, it's nothing to do with ending a string. What you really want to know is: How do you match a '*' using a regular expression? Which is what MRAB answered, courtesy of a working crystal ball: You use '\*'. Everything about the end of the string is irrelevant. (So, too, are all the comments about using [-1] or string methods. But we weren't to know that.) ChrisA