Reputation:
I have the following string:
"C:\Program Files\Application\Path\executable.exe" -- "/flag"
I am trying to split the string so that I get:
array(0) = C:\Program Files\Application\Path\executable.exe
I don't care about the rest of the array since I am just concerned about the file path not the args.
Upvotes: 0
Views: 3582
Reputation: 98092
If you don't want to mess with Mid
and InStr
, you can make use of regular expressions. For example, this will retrieve the first quoted substring (without the outer quotes) from your string:
Dim strCommandLine, strPath, re
strCommandLine = """C:\Program Files\Application\Path\executable.exe"" -- ""/flag"""
Set re = New RegExp
re.Pattern = """(.*?)"""
strPath = re.Execute(strCommandLine)(0).SubMatches(0)
Upvotes: 0
Reputation: 14041
This will do it.
dim p : p = """C:\Program Files\Application\Path\executable.exe"" -- ""/flag"
dim r : r = mid(p,2,instr(2,p,"""")-2)
Upvotes: 1