Mike Johnson Jr Mike Johnson Jr - 27 days ago 5x
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, '')