This question is related to my previous question, for which I got an answer.
Now I need to add an exception condition into the recommended regex expression. The regex expression (?<!\s)-\s+ should be applied only if the word after - is not equal to to. If it is equal to - to, then the - should be replaced with a single white space .
I tried to use a negative lookbehind (?<!to) to add the condition on to.
import re
s = "refer- ences har- ness Stand- ard Re- quired www.mypo- rtal.test.com A - it is a document, move- to store"
re.sub(r"(?<!\s)-\s+(?<!to)", "", s)
But it still returns moveto store instead of move to store.
The expected output:
references harness Standard Required www.myportal.test.com A - it is a document, move to store