Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74108
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-07-07 07:08 -0700 |
| Message-ID | <a35ecdcb-312a-4fb5-9822-209ea1823774@googlegroups.com> (permalink) |
| Subject | What is 're.M'? |
| From | rxjwg98@gmail.com |
Hi, I learn this short Python code from: http://www.tutorialspoint.com/python/python_reg_expressions.htm but I still do not decipher the meaning in its line, even after read its command explanation. It says that: 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). More specific, what does 're.M' means? I have tried several other modification to the searchObj line, without clue yet. Could you explain re.M and the following two searchObj mechanisms? Thanks, import re line = "Cats are smarter than dogs"; searchObj = re.search( r'(.*) (.*?) .*', line, re.M|re.I) # searchObj = re.search( r'(.*) (.*?) .*', line, re.M|re.I) if searchObj: print "searchObj.group() : ", searchObj.group() print "searchObj.group(1) : ", searchObj.group(1) print "searchObj.group(2) : ", searchObj.group(2) else: print "Nothing found!!"
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
What is 're.M'? rxjwg98@gmail.com - 2014-07-07 07:08 -0700
Re: What is 're.M'? Skip Montanaro <skip@pobox.com> - 2014-07-07 09:15 -0500
Re: What is 're.M'? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-07 15:25 +0100
Re: What is 're.M'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-07 14:46 +0000
Re: What is 're.M'? rxjwg98@gmail.com - 2014-07-07 07:59 -0700
Re: What is 're.M'? rxjwg98@gmail.com - 2014-07-07 08:16 -0700
Re: What is 're.M'? rxjwg98@gmail.com - 2014-07-07 08:20 -0700
Re: What is 're.M'? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-07 17:39 +0100
csiph-web