[Tutor] re module- puzzling results when matching money
Albert-Jan Roskam
fomcl at yahoo.com
Sun Aug 4 09:21:07 CEST 2013
----- Original Message -----
> From: Alex Kleider <akleider at sonic.net>
> To: Albert-Jan Roskam <fomcl at yahoo.com>
> Cc: Python Tutor <tutor at python.org>
> Sent: Sunday, August 4, 2013 1:34 AM
> Subject: Re: [Tutor] re module- puzzling results when matching money
>
> On 2013-08-03 13:30, Albert-Jan Roskam wrote:
>
>
>> Word boundary. This is a zero-width assertion that matches only at the
>> beginning or end of a word. A word is defined as a sequence of
>> alphanumeric
>> characters, so the end of a word is indicated by whitespace or a
>> non-alphanumeric character.[http://docs.python.org/2/howto/regex.html]
>> So I think it's because a dollar sign is not an alphanumeric character.
>
> I get it now, thanks.
>
>
>>
>>>>> re.findall(r"\b\e\b", "d e f")
> ^
> I'm puzzled by the presence of the '\' character before the
> 'e' above.
sorry, my bad. I forgot to delete that backslash, I meant re.findall(r"\be\b", "d e f"). Same with the other example.
More information about the Tutor
mailing list