Help with substitution

Calvelo Daniel dcalvelo at pharion.univ-lille2.fr
Fri Aug 18 17:05:41 EDT 2000


[Salman]
: Does anybody know how I can code this?
:
: I have a file and i have to make substitutions like so:
:
: (x downto y)  becomes [x:y]
:
: where x and y any integer values.

[Mike]
: Maybe something like:
: re.sub( '\(\W*([0-9]+)\W*downto\W*([0-9]+)\)', r'[\1:\2]', 'sdfsdf(23 downto
: 43)sdf' )

Mmmmh. "integer values" would like:

'\(\W*(-?[0-9]+)\W*downto\W*(-?[0-9]+)\)'

free-the-negatives!-ly y'rs

Daniel.

-- Daniel Calvelo Aros
     calvelo at lifl.fr



More information about the Python-list mailing list