Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: Regular expressions Date: Mon, 2 Nov 2015 22:58:22 -0500 Lines: 36 Message-ID: References: <662g3blobme52hfoududj27err185v2npm@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de iODqbV7CoXvIXkP++xyvLQkqzwgOLrcqV+JX9F8NmBcQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'else:': 0.03; 'expressions': 0.07; 'cc:addr:python-list': 0.09; 'python': 0.10; 'useful,': 0.13; '10:17': 0.16; '>on': 0.16; 'expressions,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Regular': 0.16; 'subject:expressions': 0.16; 'wrote:': 0.16; 'resolved': 0.18; "shouldn't": 0.18; '>': 0.18; 'solution.': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'simpler': 0.22; 'trying': 0.22; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.29; 'chase': 0.29; 'methods.': 0.29; 'url:mailman': 0.30; 'problem': 0.33; 'url:python': 0.33; 'url:listinfo': 0.34; 'list': 0.34; 'advice': 0.35; 'received:google.com': 0.35; 'nov': 0.35; 'but': 0.36; 'should': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'thanks': 0.37; 'received:209.85.213': 0.37; 'things': 0.38; 'received:209': 0.38; 'end': 0.39; 'url:mail': 0.40; 'high': 0.60; 'great': 0.63; 'asterisk': 0.84; 'complex.': 0.84; 'learn.': 0.84; 'posed': 0.84; 'seymore4head': 0.84; 'joel': 0.91; 'prone': 0.91; 'tricky': 0.93; 'unsolicited': 0.96 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:to :cc:content-type; bh=movllHCui9lnyvvXTbZbQpgwSadqfs3vKUvbDZJfmpE=; b=R+aEsDlC2iinYo+YlH5LLwO3nhIrq6UR8rsv2Sh784dlEQkxAcAo8NE3FSGnxAamv4 mIQEvsJoCdWzfs8RPkI29Uqic1ENxQk/tKlrw+wFzEVcygKfSbDOjtIN8ME3xj/Gd368 +EECy/lx1F1KbiCgvasmcfLFdvwRFygmY37XkpRCli/XIH8/myX1x3FneL5O+hqz8GS7 htULKkybvZ3etRNVnO2Y/FibkxZStoE0sNzl6RVCxfBbZ+TWtcLXdnJyevdnk4TeSQUd Iig3Zi6fQ4R9DUnISdJOVG7PyYCMxVEVbHxnhzve6WNdAO8i4tgLBzXKNUwGBTE95mA1 Se8A== X-Received: by 10.50.45.100 with SMTP id l4mr14256159igm.48.1446523102649; Mon, 02 Nov 2015 19:58:22 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ 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:98128 On Mon, Nov 2, 2015 at 10:17 PM, Seymore4Head wrote: > On Mon, 2 Nov 2015 20:42:37 -0600, Tim Chase > wrote: > > >On 2015-11-02 20:09, Seymore4Head wrote: > >> How do I make a regular expression that returns true if the end of > >> the line is an asterisk > > > >Why use a regular expression? > > > > if line[-1] == '*': > > yep(line) > > else: > > nope(line) > > > >-tkc > > > > > Because that is the part of Python I am trying to learn at the moment. > Thanks > -- > https://mail.python.org/mailman/listinfo/python-list > My completely unsolicited advice is that regular expressions shouldn't be very high on the list of things to learn. They are very useful, and very tricky and prone many problems that can and should be learned to be resolved with much simpler methods. If you really want to learn regular expressions, that's great but the problem you posed is not one for which they are the best solution. Remember simpler is better than complex. -- Joel Goldstick http://joelgoldstick.com/stats/birthdays