Replaced if / else  block with regular expression patten match

Updated SanitizeTextFiles to use a regex pattern instead of a bunch of if / else / elseif statements.