I need to replace - in test_string:
import re
test_string = "refer- ences har- ness Stand- ard Re- quired www.mypo- rtal.test.com This - is a document"
re.sub(r"[- ]", "", test_string)
The expected result:
references harness Standard Required www.myportal.test.com This - is a document
Basically, the replacement should happen only when there is no white space before -.
How can I do so? Currently I get this:
referencesharnessStandardRequiredwww.myportal.test.comThisisadocument
I appreciate of someone could also explain the solution (not just give a correct regex expression)