Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

2014-07-10 Thread rxjwg98
Hi, On a tutorial it says that '\s': Matches whitespace. Equivalent to [\t\n\r\f]. I test it with: >>> re.match(r'\s*\d\d*$', ' 111') <_sre.SRE_Match object at 0x03642BB8> >>> re.match(r'\t\n\r\f*\d\d*$', ' 111')# fails >>> re.match(r'[\t\n\r\f]*\d\d*$', ' 111') # fails >>> re.match(r'

How to write match nth grouped subexpression?

2014-07-10 Thread rxjwg98
Hi, It says that: match checks for a match only at the beginning of the string. Then, it also says that: \1...\9Matches nth grouped subexpression. I don't know how to write a script to include grouped subexpression in match? Thanks, -- https://mail.python.org/mailman/listinfo/python-l

Re: Question about metacharacter '*'

2014-07-07 Thread rxjwg98
On Sunday, July 6, 2014 8:09:57 AM UTC-4, Devin Jeanpierre wrote: > On Sun, Jul 6, 2014 at 4:51 AM, wrote: > > > Hi, > > > > > > I just begin to learn Python. I do not see the usefulness of '*' in its > > > description below: > > > > > > > > > > > > > > > The first metacharacter for repe

Re: What is 're.M'?

2014-07-07 Thread rxjwg98
On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to

Re: What is 're.M'?

2014-07-07 Thread rxjwg98
On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to

Re: What is 're.M'?

2014-07-07 Thread rxjwg98
On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to

What is 're.M'?

2014-07-07 Thread rxjwg98
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

Re: How to write this repeat matching?

2014-07-07 Thread rxjwg98
On Sunday, July 6, 2014 3:26:44 PM UTC-4, Ian wrote: > On Sun, Jul 6, 2014 at 12:57 PM, wrote: > > > I write the following code: > > > > > > ... > > > import re > > > > > > line = "abcdb" > > > > > > matchObj = re.match( 'a[bcd]*b', line) > > > > > > if matchObj: > > >print "ma

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
On Sunday, July 6, 2014 4:32:14 PM UTC-4, Larry Hudson wrote: > On 07/06/2014 08:03 AM, rxjw...@gmail.com wrote: > > > > > Thanks. I do not want to waste everyone's time. For a jump start, there are > > > small errors making me frustrating. Your help does help me, confirm the > > usage > >

How to write this repeat matching?

2014-07-06 Thread rxjwg98
Hi, On Python website, it says that the following match can reach 'abcb' in 6 steps: . A step-by-step example will make this more obvious. Let's consider the expression a[bcd]*b. This matches the letter 'a', zero or more letters from the class [bcd], and finally ends with a 'b'. Now

What is the difference between matchObj.group() and matchObj.group(0)

2014-07-06 Thread rxjwg98
Hi, I cannot get the difference between matchObj.group() and matchObj.group(0), Although there definitions are obvious different. And group() mentions 'tuple'. tuple means all the elements in line object? Match Object Methods Description group(num=0) This method returns entire match (or speci

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
On Sunday, July 6, 2014 10:18:53 AM UTC-4, Rick Johnson wrote: > On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj...@gmail.com wrote: > > > When I get match result: > > > py>pattern='abcd' > > > py>prog = re.compile(pattern) > > > py>string='abcd' > > > py>result = prog.match(string) > > > py>re

Re: Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
On Sunday, July 6, 2014 8:54:42 AM UTC-4, Tim Chase wrote: > On 2014-07-06 05:13, rxjw...@gmail.com wrote: > > > What I get on Python console: > > > > > > $ python > > > Python 2.7.5 (default, Oct 2 2013, 22:34:09) > > > [GCC 4.8.1] on cygwin > > > Type "help", "copyright", "credits" or "li

Why is it different from the example on the tutorial?

2014-07-06 Thread rxjwg98
Hi, I type the following sample codes on Python, but it echoes differently. Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. >>> >>> import re >>> p = re.compile('ab*') >>> p

Question about metacharacter '*'

2014-07-06 Thread rxjwg98
Hi, I just begin to learn Python. I do not see the usefulness of '*' in its description below: The first metacharacter for repeating things that we'll look at is *. * doesn't match the literal character *; instead, it specifies that the previous character can be matched zero or more times, ins

This Python script cannot open by a editor?

2014-07-04 Thread rxjwg98
Hi, I am learning a Python Tool from web: http://www.ohwr.org/projects/hdl-make/wiki/Quick-start-new I download the program to Ubuntu 12.04. I find that in the folder it is shown as hdlmake-v1.0, 37.8 KB Python Script. I remember that script file can be loaded to an editor to read its content. B

What use with Python

2014-07-01 Thread rxjwg98
Hi, I am new to Python. Weeks ago, I was asked about Python questions on an interview. Now I want to learn Python, but I do not know what I can do with it on a PC. Especially I would like to do something interesting instead of some text search etc. Python may can do more than I realize now. Cou