【发布时间】:2013-11-30 17:02:31
【问题描述】:
我有这个字符串:
Process.exe /Switch=Value /Switch="C:\Path with spaces\file.txt" wrong argument
我想捕捉这些部分:
· 1st Match: Process.exe · 2nd Match: /Switch=Value · 3rd Match: /Switch="C:\Path with spaces\file.txt" · 4th Match: wrong · 5th Match: argument
正则表达式需要用于一般用途(带有真实参数的过程),不仅适用于这种情况。
这是我正在尝试的:
Dim DebugArguments As String =
"HotkeyMaker.exe /Hotkey=Escape /run=""c:\folder with spaces\notepad.exe"""
For Each match As Match In Regex.Matches(DebugArguments, "([^\s]+[^""])")
MsgBox(match.Value)
Next match
【问题讨论】:
-
在参数的布局规则中断之前,您无法解析它。有什么你能想到的吗?
-
是否总是有 5 个且只有 5 个参数?
-
@ridgerunner 不,这只是一个例子,参数的数量是未定义的
-
@sin,对不起,我的英文不太好,什么意思?,语法类似于一些微软应用程序,例如 SC.exe 命令:
sc.exe config themes type="own",但也带有@ 987654325@ 字符。