Re: Exact match with regular expression

2008-11-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Mr.SpOOn
wrote:

> On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro
> <[EMAIL PROTECTED]> 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. :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Exact match with regular expression

2008-11-03 Thread Mr . SpOOn
On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro
<[EMAIL PROTECTED]> wrote:
> In message <[EMAIL PROTECTED]>, 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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Exact match with regular expression

2008-11-01 Thread Rob Williscroft
Lawrence D'Oliveiro wrote in news:[EMAIL PROTECTED] in 
comp.lang.python:

> In message <[EMAIL PROTECTED]>, 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.

Saying "Thank You" is what email is for, which in this case is
what Mr.SpOOn did:

> Read (and bookmark) this:
> >
> > http://www.python.org/doc/2.5.2/lib/re-syntax.html
> >
> > You want the 3rd item down about the "$" special character.
> 
> Great, thanks.
> When I read about the symbol in the tutorial I didn't realize 
> what was it for.

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Exact match with regular expression

2008-10-31 Thread Shawn Milochik
On Fri, Oct 31, 2008 at 8:57 PM, Lawrence D'Oliveiro
<[EMAIL PROTECTED]> wrote:
> In message <[EMAIL PROTECTED]>, 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.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Exact match with regular expression

2008-10-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, 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


Re: Exact match with regular expression

2008-10-26 Thread Lie Ryan
On Sun, 26 Oct 2008 17:51:29 +0100, Mr.SpOOn wrote:

> 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: 'aabbb'
> 
 m = p.match('aabbb')
 m.group()
> 'aabbb'
> 
> But I'd like to get None with this: 'aabb' Instead it matches the
> first part:
> 
 m = p.match('aabb')
 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.

re.compile('a*b*$')

$ matches the end of a string, or in MULTILINE mode, the end of a line 
(right before newline)

Symmetrically, ^ matches the start of a string, or in MULTILINE mode, the 
start of a line (including the start of the string)


--
http://mail.python.org/mailman/listinfo/python-list


Re: Exact match with regular expression

2008-10-26 Thread Rob Williscroft
Mr.SpOOn wrote in news:mailman.3069.1225039892.3487.python-
[EMAIL PROTECTED] in comp.lang.python:

> 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: 'aabbb'
> 
 m = p.match('aabbb')
 m.group()
> 'aabbb'
> 
> But I'd like to get None with this: 'aabb'
> Instead it matches the first part:
> 
 m = p.match('aabb')
 m.group()
> 'aab'

Read (and bookmark) this:

http://www.python.org/doc/2.5.2/lib/re-syntax.html

You want the 3rd item down about the "$" special character.
 
>>> p = re.compile('a*b*$')
>>> m = p.match('aabb')
>>> m is None
True
>>> m = p.match('aabbb')
>>> m.group()
'aabbb'

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
--
http://mail.python.org/mailman/listinfo/python-list


Exact match with regular expression

2008-10-26 Thread Mr . SpOOn
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: 'aabbb'

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

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

>>> m = p.match('aabb')
>>> 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.
--
http://mail.python.org/mailman/listinfo/python-list