I have a string in Python:
string = "Hello I am a 21 !string. In section 3.2.F.1.2 we covered 1topic X. On the oth1er hand, in section 1.2.F.1.1 we covered Y. Lastly, in section F.3.2 we 23 covered Z."
I need to remove the random numbers and punctuation from the text such that:
"a 21 !string" --------> "...a string..." and...
"covered 1 topic x." ---------> "covered topic"
My final string should then be:
filtered = "hello i am a string in section 3.2.F.1.2 we covered topic x on the other hand in section 1.2.F.1.1 we covered y lastly in section 1.1.F.3.2 we covered z"
...such that the codes "3.2.F.1.2", "1.2.F.1.1", and "1.1.F.3.2" were not affected by this.
I was able to generate a regex expression to specify the codes with:
regex_codes = "[\d\.]{1,4}F[\.\d]{1,4}"
all_nums_punct = "[0-9 _.,!"'/$]*"
What I cannot figure out is how to "select and remove all numbers and punctuation (all_nums_punct) except these codes (regex_code) pattern".
I tried using a "negative lookahead" pattern to ignore everything that starts with my codes from a previous stackOverflow article, but my selection is not selecting anything.