Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98726
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Terry Reedy <tjreedy@udel.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: Is it useful for re.M in this example? |
| Date | Thu, 12 Nov 2015 22:32:35 -0500 |
| Lines | 33 |
| Message-ID | <mailman.282.1447385576.16136.python-list@python.org> (permalink) |
| References | <fc8a4061-5156-41c8-bfd7-d9a8da462418@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de bzit8WSPYAchINki37la4AK8e/yRSI8DEcczYh7LPKDw== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'string)': 0.09; 'python': 0.10; 'jan': 0.11; 'doubly': 0.16; 'example?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'routinely': 0.16; 'string).': 0.16; 'wrote:': 0.16; 'beginner': 0.18; '(not': 0.20; 'appears': 0.23; 'import': 0.24; 'examples': 0.24; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'skip:# 10': 0.27; 'function': 0.28; '"no': 0.29; 'omitted': 0.29; 'project:': 0.29; 'routine': 0.29; 'tutorial': 0.29; 'print': 0.30; 'url:python': 0.33; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'end': 0.39; 'to:addr:python.org': 0.40; 'no.': 0.62; 'below.': 0.66; 'irrelevant': 0.84; 'subject:this': 0.85; 'received:fios.verizon.net': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | pool-173-59-124-74.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| In-Reply-To | <fc8a4061-5156-41c8-bfd7-d9a8da462418@googlegroups.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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:98726 |
Show key headers only | View raw
On 11/12/2015 4:34 PM, fl wrote: > I follow a web site on learning Python re. I have read the function > description of re.m, as below. > re.M Makes $ match the end of a line (not just the end of the string) and > makes ^ match the start of any line (not just the start of the string). > > But I don't see the reason to put re.M in the example project: > > #!/usr/bin/python > import re > > line = "Cats are smarter than dogs"; > > matchObj = re.match( r'dogs', line, re.M|re.I) > if matchObj: > print "match --> matchObj.group() : ", matchObj.group() > else: > print "No match!!" > > The tutorial (http://www.tutorialspoint.com/python/python_reg_expressions.htm) > is for a beginner as I. Is there something I don't see in the example? No. The use of re.M in the examples is doubly irrelevant since there is no \n in line and no $ in the pattern. Re.I is also not relevant since there is no case-insensitive matchin. It appears that the author routinely uses flags=re.M|re.I. For a tutorial, I would have omitted either omitted them or explained them as routine boilerplate. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Is it useful for re.M in this example? fl <rxjwg98@gmail.com> - 2015-11-12 13:34 -0800 Re: Is it useful for re.M in this example? John Gordon <gordon@panix.com> - 2015-11-12 22:00 +0000 Re: Is it useful for re.M in this example? Terry Reedy <tjreedy@udel.edu> - 2015-11-12 22:32 -0500
csiph-web