first, I know there are similar questions but I could not find anything that really matched my case.
I have a large string from which I want to cut out some texts.
import re
largeString = 'abcdefgTHIS NEEDS TO GO?abdehdfenTHIS NEEDS TO GO TOO?asjdhnasjdf'
itemList =['THIS NEEDS TO GO?','THIS NEEDS TO GO TOO?']
<<<some code>>>
Out: 'abcdefgabdehdfenasjdhnasjdf
I tried this:
for i in itemList:
largeString = re.sub(str(i), '', largeString.rstrip())
The Problem is the question mark in the search strings- I know that usually I would do 'THIS NEEDS TO GO\?'. Unfortunately, the list is very large and I cannot change it manually.
Is there a way to make regex ignore the question mark feature?
Any help or idea is appreciated!
Thanks!