如何取自定义的参数
下面有一行命令
COPYFILE "D:\AAA.TXT" "E:\AA\BB.DOC" "E:\AA\ABC.XLS"
如果取得命令后面的参数如何取得(所有参数值的左右两边都是双引号,参数和参数之间是一个半角空格)?
不知道.Net有没有取参数的函数,我记的vbs是有相关功能的,可以取到类似格式的参数。
我试着用正则表达式取参数,代码如下:
'''''''''''''''''''''''''''''''''''''''''''''''''''''Const PATTERA As String = """.+"""Dim reg As RegexDim regResult As MatchDim startIndex As IntegerDo regResult = reg.Match(text, startIndex) If regResult.Success = False Then Exit Do End If startIndex = regResult.Index + 1 ......Loop'''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim str As String = "COPYFILE ""D:\AAA.TXT"" ""E:\AA\BB.DOC"" ""E:\AA\ABC.XLS""" Dim reg As Regex = New Regex(""".+?""") For Each m As Match In reg.Matches(str) Console.WriteLine(m.Value) Next