a string problem

micklee74 at hotmail.com micklee74 at hotmail.com
Tue Jun 13 10:37:15 EDT 2006


John Salerno wrote:
> 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.

thanks..actually i had seen \b in the docs before, just that it slipped
my mind when i was doing the coding. was even meddling with look aheads
..which is not the answer anyway.
well, since re has the \b, was wondering why there is no implementation
of it in strings. So the idea of looking at the source or re on how
it's done came to my mine..i suppose we have to go down to viewing the
C source then..:-)




More information about the Python-list mailing list