Mike Johnson Jr Mike Johnson Jr - 7 months ago 26
Python Question

In python how can I add a special case to a regex function?

Say for example I want to remove the following strings from a string:

remove = ['\\u266a','\\n']

And I have regex like this:

string = re.sub('[^A-Za-z0-9]+', '', string)

How can I add "remove" to my regex function?


you can always remove them before doing the regex like so:

remove = ['\\u266a','\\n']

for substr in remove:
    string.replace(substr, '')