I'm trying to write a regex statement in Python with a negated pattern. I want to match a pattern that doesn't start with a U followed by a W and optionally ends with a 1. Below are some examples.
TUW1TH > # regex does not get applied
JUWRG > # regex does not get applied
BUIUW1 > # regex does not get applied
ATWKO > ATW KO # regex applies and space is added after the W
EWRG > E WRG # regex applies and space is added after the W
AGDTWSD > AGDTW SD # regex applies and space is added after the W
Below is the regex statement I tried to use:
re.sub(ur"[^U]W[^?1]", ur"W ", word)
1?instead of[^?1]?1after theW(assuming it is not preceeded by aU)? For example, "EW1RG" -> ???. You didn't give an example of a case like that.