I am reading in a file and trying to replace every occurrence of a regex match with that match but with the white space stripped. For example, the regex which matches correctly on what I want in my document is '([0-9]+\s(st|nd|rd|th))' so that anything inside of the document of the form...
1 st, 2 nd, 33 rd, 134 th etc. will be matched.
What I want is to simply write a new file with each of those occurrences in the original file replaced with the white space removed.
I have played with a few things like re.findall and re.sub but I cant quite figure out how to write the full document but with just the substring matches replaced without white space.
Thanks for the help.