I have a script that compiles an .exe file and runs the --tree=all of that .exe. This returns the directory where the file is stored and I want to use that path to run it.
This is the output I get from --tree=all
| | +-out\windows-x86-MD-mbcs-vs2008-rel\bin\VisualStudio08-32bit.exe
so I used the following to get rid of the special characters:
line = re.sub('[|+ -]', '', lines)
This works, but it removes all instances of - which results in this:
out\windowsx86MDmbcsvs2008rel\bin\VisualStudio0832bit.exe
But I want to get this:
out\windows-x86-MD-mbcs-vs2008-rel\bin\VisualStudio08-32bit.exe
How do I make sure only the first instance of - is removed, and the rest is left alone?
If you can rely on
-preceding the name and you’re not adamant on using a regex:Output:
out\windows-x86-MD-mbcs-vs2008-relin\VisualStudio08-32bit.exe