a string problem

John Salerno johnjsal at NOSPAMgmail.com
Tue Jun 13 10:26:32 EDT 2006


micklee74 at hotmail.com wrote:

> just curious , if RE has the \b and it works, can we look into the
> source of re and see how its done for \b ?

I had a look in the sre module (which re seems to import), but I 
couldn't find much. I'm not the best at analyzing source code, though. :)

What is it you want to know about \b? It searches for the empty string 
before and after a word (word being an alphanumeric character that can 
include underscores).

A little more specific info is in the docs:

Matches the empty string, but only at the beginning or end of a word. A 
word is defined as a sequence of alphanumeric or underscore characters, 
so the end of a word is indicated by whitespace or a non-alphanumeric, 
non-underscore character. Note that \b is defined as the boundary 
between \w and \ W, so the precise set of characters deemed to be 
alphanumeric depends on the values of the UNICODE and LOCALE flags. 
Inside a character range, \b represents the backspace character, for 
compatibility with Python's string literals.



More information about the Python-list mailing list