File: class/Extras/Code/Text/re-subst.py

# substitutions (replace occurrences of patt with repl in string)

import re  
print re.sub('[ABC]', '*', 'XAXAXBXBXCXC')
print re.sub('[ABC]_', '*', 'XA-XA_XB-XB_XC-XC_')



[Home page] Books Code Blog Python Author Train Find ©M.Lutz