使用正则表达式 powershell 匹配两个逗号之间或 ," 和 " 之间的所有字符

Ken*_*oku 2 regex csv powershell

使用 powershell 正则表达式 我希望它找到两个逗号之间或 ," 和 ", 之间的第一个匹配项

例子:

"0x00000000","What do you want to eat? fish, meat or\n eggs?",""
"0x00030002","What do you want to eat?",""
0x00030002,What do you want to eat?,
Run Code Online (Sandbox Code Playgroud)

我希望它变成:

What do you want to eat? fish, meat or eggs?
What do you want to eat?
What do you want to eat?
Run Code Online (Sandbox Code Playgroud)

我尝试了这段代码,但它的行为不正确:

(?<=,"|\?<=,).*(?=",.*?|\?=,.*?)

iRo*_*Ron 5

我不会使用正则表达式(这有一些陷阱),而是使用本机ConvertFrom-Csvcmdlet

$List = @'
"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?,
"0x00000000","What do you want to eat? ""fish"", ""meat"" or ""eggs?"""
'@ -Split '\r?\n'

$List | ConvertFrom-Csv -Header Hex, String, Rest | Select-Object -Expand String

What do you want to eat? fish, meat or eggs?
What do you want to eat?
What do you want to eat? fish
What do you want to eat?
What do you want to eat? "fish", "meat" or "eggs?"
Run Code Online (Sandbox Code Playgroud)