I have a .csv in the following file format:
In: "bob","1234 Main St, New York, NY","cool guy"
I am looking to remove double quotes that don't have a comma inside:
Out: bob,"1234 Main St, New York, Ny",cool guy
Is there a way to do this in Powershell?
I have checked:
解决方案$csv = 'C:\path\to\your.csv'
(Get-Content $csv) -replace '(?m)"([^,]*?)"(?=,|$)', '$1' |
Set-Content $csv
The regex (?m)"([^,]*?)"(?=,|$) is matching any " + 0 or more non-commas + " before a comma or end of line (achieved with a positive look-ahead and a multiline option (?m) that forces $ to match a newline, not just the end of string).