I need to remove lines of a .txt file that start with certain values, say anything with a digit 0-9 or an !.
I have already written a function noNumsExclam that looks something like this:
def noNumsExclam(s: str) -> bool:
return bool(re.search("regexpattern", s))
It returns True if the string contains what matches the pattern and False if it does not. I have confirmed this is working on my code.
Now I want to use the function noNumsExclam to remove the lines that return "True" and store the text with deleted lines in a new variable.
I think an easier solution would be to use re.sub() however, I have been given this specific constraint for the problem.