find and replace with regular expressions

Paul McGuire ptmcg at austin.rr.com
Thu Jul 31 18:58:01 EDT 2008


On Jul 31, 3:07 pm, chrispoliq... at gmail.com wrote:
>
> middle_abbr = re.compile('[A-Za-z0-9]\.[A-Za-z0-9]\.')
>

When defining re's with string literals, it is good practice to use
the raw string literal format (precede with an 'r'):
    middle_abbr = re.compile(r'[A-Za-z0-9]\.[A-Za-z0-9]\.')

What abbreviations have numeric digits in them?

I hope your input string doesn't include something like this:
    For a good approximation of pi, use 3.1.

-- Paul



More information about the Python-list mailing list