Suppose such a list,
l = ['\\number', '\\A', '\\b', '\\B', '\\d', '\\D', '\\s', '\\S', '\\w', '\\W', '\\Z']
I'd like to get a result:
l = ['\number', '\A', '\b', '\B', '\d', '\D', '\s', '\S', '\w', '\W', '\Z']
Handle it with regex
In [35]: [re.sub(r'\\(?=\\w+)', '',i) for i in l]
Out[35]:
['\\',
'\\number',
'\\A',
'\\b',
'\\B',
'\\d',
'\\D',
'\\s',
'\\S',
'\\w',
'\\W',
'\\Z']
It failed to work as I expected.
How to accomplish such a task using regex?