Description
Well assuming we clean up your source text to include the proper closing quotes, then this expression will:
- Match all quote comma delimited text
- Capture the leading comma and quote and closing quote, along with the included text into group 0
- Trim off the leading and closing quotes and place that value into capture group 1
- Allow values to contain escaped quote sequences like
\"
and ""
.
(?:^|,)"((?<=")(?:[^"]*|\\"|"")*?)"(?=[,\r\n]|\Z)
Example
Live Demo: http://www.rubular.com/r/NSSxdHWcDM
Sample Text
"1000000000000000","","","","email1@yahoo.com","1random_value"""
"2000000000000000","","","","email2@yahoo.com","2random_value\""
Capture Groups
[0][0] = "1000000000000000"
[0][1] = 1000000000000000
[1][0] = ,""
[1][1] =
[2][0] = ,""
[2][1] =
[3][0] = ,""
[3][1] =
[4][0] = ,"email1@yahoo.com"
[4][1] = email1@yahoo.com
[5][0] = ,"1random_value"""
[5][1] = 1random_value""
[6][0] = "2000000000000000"
[6][1] = 2000000000000000
[7][0] = ,""
[7][1] =
[8][0] = ,""
[8][1] =
[9][0] = ,""
[9][1] =
[10][0] = ,"email2@yahoo.com"
[10][1] = email2@yahoo.com
[11][0] = ,"2random_value\""
[11][1] = 2random_value\"