Regex to pick commas outside quotes in Matlab

I tried the solution for the picking commas outside quotes using regexp in Matlab (MacOSX)

str='"This string has comma , inside the quotes", 2nd string, 3rd string'

I expect the three tokens

 "This string has comma , inside the quotes"
  2nd string
  3rd string

I used the following but get an empty solution

regexp(str, '^([^"]|"[^"]*")*?(,)')

ans =

     []

What should be correct regexp grammar for this.


Source: regex

Leave a Reply