Aaron -

Here's a pyparsing approach (requires latest 1.3 pyparsing version).
It may not be as terse or fast as your regexp, but it may be easier to
maintain.

By defining floatNum ahead of DOT in the scanner definition, you
specify the dot-containing expressions that you do *not* want to have
dots converted to colons.

-- Paul

===================
from pyparsing import Word,Literal,replaceWith, Combine, nums

DOT = Literal(".").setParseAction( replaceWith(":") )
floatNum = Combine( Word(nums) + "." + Word(nums) )

scanner = floatNum | DOT

testdata = "'375 mi. south of U.C.B is 3.4 degrees warmer."

print scanner.transformString( testdata )
===================
prints out:
'375 mi: south of U:C:B is 3.4 degrees warmer:

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

Reply via email to