Re: Question about metacharacter '*'

2014-07-07 Thread Mark Lawrence
On 07/07/2014 19:51, rxjw...@gmail.com wrote: Will you please do something about the double spaced google crap that you keep sending, I've already asked you twice. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- Th

Re: Question about metacharacter '*'

2014-07-07 Thread Devin Jeanpierre
On Mon, Jul 7, 2014 at 11:51 AM, wrote: > Would you give me an example using your pattern: `.*` -- `.`? > I try it, but it cannot pass. (of course, I use it incorrectly) Those are two patterns. Python 3.4.1 (default, Jul 7 2014, 13:22:02) [GCC 4.6.3] on linux Type "help", "copyright", "credits

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: Question about metacharacter '*'

2014-07-07 Thread Ian Kelly
On Sun, Jul 6, 2014 at 4:49 PM, MRAB wrote: > \d also matches more than just [0-9] in Unicode. I think that anything matched by \d will also be accepted by int(). >>> decimals = [c for c in (chr(i) for i in range(17 * 2**16)) if >>> unicodedata.category(c) == 'Nd'] >>> len(decimals) 460 >>> re.

Re: Question about metacharacter '*'

2014-07-06 Thread Devin Jeanpierre
The reason I did not use \d\d* or \d+ or ^\d+$ or any number of more-correct things was because the OP was new to regexps. -- Devin On Sun, Jul 6, 2014 at 3:49 PM, MRAB wrote: > On 2014-07-06 18:41, Albert-Jan Roskam wrote: >> >> >> >> >>> In article , >>> Rick Johnson wrote: >>> As an asi

Re: Question about metacharacter '*'

2014-07-06 Thread MRAB
On 2014-07-06 18:41, Albert-Jan Roskam wrote: In article , Rick Johnson wrote: As an aside i prefer to only utilize a "character set" when nothing else will suffice. And in this case r"[0-9][0-9]*" can be expressed just as correctly (and less noisy IMHO) as r"\d\d*". Even better, r"\d+"

Re: Question about metacharacter '*'

2014-07-06 Thread Albert-Jan Roskam
>In article , > Rick Johnson wrote: > >> As an aside i prefer to only utilize a "character set" when >> nothing else will suffice. And in this case r"[0-9][0-9]*" >> can be expressed just as correctly (and less noisy IMHO) as >> r"\d\d*". > >Even better, r"\d+" I tend tot do that too, even th

Re: Question about metacharacter '*'

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 12:38:23 PM UTC-5, Rick Johnson wrote: > r'\s*#[^\n]' Well, there i go not testing again! r'\s*#[^\n]*' -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about metacharacter '*'

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 11:47:38 AM UTC-5, Roy Smith wrote: > Even better, r"\d+" > >>> re.search(r'(\d\d*)', '111aaa222').groups() > ('111',) > >>> re.search(r'(\d+)', '111aaa222').groups() > ('111',) Yes, good catch! I had failed to reduce your original pattern down to it's most fundamental aspe

Re: Question about metacharacter '*'

2014-07-06 Thread Roy Smith
In article , Rick Johnson wrote: > As an aside i prefer to only utilize a "character set" when > nothing else will suffice. And in this case r"[0-9][0-9]*" > can be expressed just as correctly (and less noisy IMHO) as > r"\d\d*". Even better, r"\d+" >>> re.search(r'(\d\d*)', '111aaa222').grou

Re: Question about metacharacter '*'

2014-07-06 Thread Rick Johnson
[CONTINUED FROM LAST REPLY...] Likewise if your intent is to filter out any match strings which contain non-digits, then define the start and stop points of the pattern: # Match only if all are digits >>> re.match(r'\d\d*$', '111aaa222') # fails # Match only if all are digits and, # allow leadin

Re: Question about metacharacter '*'

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 10:50:13 AM UTC-5, Devin Jeanpierre wrote: > In related news, the regexp I gave for numbers will match "1a". Well of course it matched, because your pattern defines "one or more consecutive digits". So it will match the "1" of "1a" and the "11" of "11a" likewise. As an asi

Re: Question about metacharacter '*'

2014-07-06 Thread Devin Jeanpierre
In related news, the regexp I gave for numbers will match "1a". -- Devin On Sun, Jul 6, 2014 at 8:32 AM, MRAB wrote: > On 2014-07-06 13:09, 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 '*'

Re: Question about metacharacter '*'

2014-07-06 Thread MRAB
On 2014-07-06 13:09, 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 repeating things that we'll look at is *. * doesn't match the literal character *;

Re: Question about metacharacter '*'

2014-07-06 Thread Devin Jeanpierre
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 repeating things that we'll look at is *. * > doesn't > match the literal character *; instead, it specifies that th