Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Exact match with regular expression (http://www.velocityreviews.com/forums/t641628-exact-match-with-regular-expression.html)

Mr.SpOOn 10-26-2008 04:51 PM

Exact match with regular expression
 
Hi,
I'd like to use regular expressions to parse a string and accept only
valid strings. What I mean is the possibility to check if the whole
string matches the regex.

So if I have:

>>> p = re.compile('a*b*')


I can match this: 'aaaaaabbb'

>>> m = p.match('aaaaaabbb')
>>> m.group()

'aaaaaabbb'

But I'd like to get None with this: 'aabDDDDb'
Instead it matches the first part:

>>> m = p.match('aabDDDDb')
>>> m.group()

'aab'

I know this is the expected behaviour, but I'm sure it should be
possible doing what I said.
Are there other methods I don't know about in the re module?

Thanks.

Lawrence D'Oliveiro 11-01-2008 12:57 AM

Re: Exact match with regular expression
 
In message <Xns9B43B11B2906ArtwfreenetREMOVEcouk@216.196.109. 145>, Rob
Williscroft wrote:

> Read (and bookmark) this:
>
> http://www.python.org/doc/2.5.2/lib/re-syntax.html


Funny how you never get a thank-you when you tell people to RTFM.

Shawn Milochik 11-01-2008 02:45 AM

Re: Exact match with regular expression
 
On Fri, Oct 31, 2008 at 8:57 PM, Lawrence D'Oliveiro
<ldo@geek-central.gen.new_zealand> wrote:
> In message <Xns9B43B11B2906ArtwfreenetREMOVEcouk@216.196.109. 145>, Rob
> Williscroft wrote:
>
>> Read (and bookmark) this:
>>
>> http://www.python.org/doc/2.5.2/lib/re-syntax.html

>
> Funny how you never get a thank-you when you tell people to RTFM.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



Hmmm. Kind of odd. Someone involved in the language they're having
trouble with wrote some documentation for the exact thing they're
asking for, you tell them where it is, and that doesn't deserve
thanks?

Something's wrong here. Well, it's about time for that which must be
read by everyone on the Internet to be mentioned again.

If you haven't read this yet, read this:
http://www.catb.org/~esr/faqs/smart-questions.html

Especially if you have asked for help and not gotten what you wanted.
Especially if people ignore your questions.
Especially if people give answers that don't help you.

Mr.SpOOn 11-03-2008 12:37 PM

Re: Exact match with regular expression
 
On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro
<ldo@geek-central.gen.new_zealand> wrote:
> In message <Xns9B43B11B2906ArtwfreenetREMOVEcouk@216.196.109. 145>, Rob
> Williscroft wrote:
>
>> Read (and bookmark) this:
>>
>> http://www.python.org/doc/2.5.2/lib/re-syntax.html

>
> Funny how you never get a thank-you when you tell people to RTFM.


My fault :\
I said "thank you" to Rob, but I just sent a private message. It's
just that I did a reply and not reply to all.

Anyway, I RTFM and solved my problem :)

Thanks again,
Bye

Lawrence D'Oliveiro 11-04-2008 08:59 PM

Re: Exact match with regular expression
 
In message <mailman.3423.1225717725.3487.python-list@python.org>, Mr.SpOOn
wrote:

> On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro
> <ldo@geek-central.gen.new_zealand> wrote:
>
>> Funny how you never get a thank-you when you tell people to RTFM.

>
> My fault :\
> I said "thank you" to Rob, but I just sent a private message. It's
> just that I did a reply and not reply to all.


That's OK. My fault for not realizing. :)


All times are GMT. The time now is 11:20 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.