Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Tim Chase Newsgroups: comp.lang.python Subject: Re: Regular expressions Date: Wed, 4 Nov 2015 20:48:15 -0600 Lines: 25 Message-ID: References: <662g3blobme52hfoududj27err185v2npm@4ax.com> <56397a18$0$11094$c3e8da3@news.astraweb.com> <56397FC6.9040700@gmail.com> <563abee1$0$1614$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de mVLZIs0dvZ+wGeey9L1HbQf2SOMF8NvGufu+k0o4DL+Q== 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; 'matches': 0.07; 'grep': 0.09; 'literal': 0.09; '"grep': 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Regular': 0.16; 'subject:expressions': 0.16; "tim's": 0.16; 'wrote:': 0.16; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'this.': 0.28; "d'aprano": 0.33; 'steven': 0.33; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'charset:us- ascii': 0.37; 'does': 0.39; 'to:addr:python.org': 0.40; 'more': 0.63; 'received:46': 0.63 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1446691777264:2461975930 X-MC-Ingress-Time: 1446691777264 In-Reply-To: <563abee1$0$1614$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) X-AuthUser: tim@thechases.com 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:98268 On 2015-11-05 13:28, Steven D'Aprano wrote: > > I tried Tim's example > > > > $ seq 5 | grep '1*' > > 1 > > 2 > > 3 > > 4 > > 5 > > $ > > I don't understand this. What on earth is grep matching? How does > "4" match "1*"? The line with "4" matches "zero or more 1s". If it was searching for a literal "1*" (as would happen with fgrep or "grep -F"), it would return no results: $ seq 5 | fgrep '1*' $ -tkc