使用 powershell 正则表达式我希望它能找到两个逗号之间或 ," 和 ", 之间的第一个匹配项
示例:
"0x00000000","What do you want to eat? fish, meat or eggs?",""
"0x00030002","What do you want to eat?",""
0x00000000,What do you want to eat? fish, meat or eggs?,
0x00030002,What do you want to eat?,
我希望它变成:
What do you want to eat? fish, meat or eggs?
What do you want to eat?
What do you want to eat? fish, meat or eggs?
What do you want to eat?
我尝试了这段代码,但它的行为不正确:
(?<=,"|\?<=,).*(?=",.*?|\?=,.*?)
我针对您的问题尝试了下面的正则表达式,并且在第 1 组值中捕获了所需的字段。
,"{0,1}(.*)"{0,1},
我在 PowerShell 上验证了结果,如下所示。
[RegEx]::Matches('0x00000000,What do you want to eat? fish, meat or eggs?,' , ',"{0,1}(.*)"{0,1},').groups[1].value