I have some text
>>> import re
>>> text = 'wo__RF**81@t=(181,810)'
and I want to replace the 'wo__RF'
portion with ''
explicitely using regular expressions. This pattern:
>>> pattern = '\A([\w]+)[@+-/*]*'
Will match and pull out the characters to remove
>>> re.findall(pattern, text)
Out[6]: ['wo__RF']
But includes the trailing operators when using re.sub
>>> re.sub(pattern, '', text)
Out[7]: '81@t=(181,810)'
How would I make this output look like this?
Out[7]: '**81@t=(181,810)'
----edit----
Modifying the pattern to:
>>> pattern = '\A([\w]+)[@+-/*]*'
produces the same output
Out[7]: '81@t=(181,810)'
---- edit 2 ----
Remove the capture groups
>>> pattern = '\A[\w]+[@+/*-]*'
>>> re.sub(pattern, '', text)
Out[11]: '81@t=(181,810)'