In Python, how does one use regular expression to replace repeated consecutive letters with a single expression. Here is an example. The original string is
txt = 'SEP 2323'
I would like to turn that into 'SEP_2323' with one '_' no matter how many spaces there are in txt.
The following does not work since it gives the same number of '_' as the number of ' '.
a = re.sub("\s","_",txt)