Begineer Question : Global string substitution with re

Fredrik Lundh fredrik at pythonware.com
Mon Sep 22 05:45:38 EDT 2003


peter leonard wrote:

> import re
> line = "This is the first ratio, 170/37, and this is the second  170/37 "
>
> def normalise(text):
>
>     #Tag fractions
>     fraction = r'(\s+\d+\/\d+\s+)'

the second \s+ doesn't match the comma after the first ratio.

</F>








More information about the Python-list mailing list