0

I have a variable with values like

 l_buffer := '10223,1600003B,Admin Officer,00000004,"Org Land, Inc.",ORGA03,ORGA03 HR & Admin'

Now I am using while condinition to check the comma delimeted columns. But in that case it is considering "Org Land, Inc." as two columns

Org Land and Inc. But because it is enclosed with double quotes it should be considered as one. Is there a way regex can solve this issue ?

sreekem bose
  • 451
  • 3
  • 12
  • 28
  • Use [`[^,]+|"[^"]*"`](https://regex101.com/r/wO3rC6/1). – Wiktor Stribiżew May 29 '16 at 11:53
  • You asked this question already, just one day ago, why open it again? –  May 29 '16 at 11:56
  • Possible duplicate of [Comma-delimited fields in a csv file in plsql](http://stackoverflow.com/questions/37502875/comma-delimited-fields-in-a-csv-file-in-plsql) –  May 29 '16 at 11:57
  • Possible duplicate of [Regex to split a CSV](http://stackoverflow.com/questions/18144431/regex-to-split-a-csv) – Ro Yo Mi May 29 '16 at 13:24

1 Answers1

0

See also an earlier post I made about this same problem:

  • divide your sample text on the comma delimits
  • will process empty values
  • will ignore double quoted commas, providing double quotes are not nested
  • trims the delimiting comma from the returned value
  • trims surrounding quotes from the returned value

The Regex

 (?:^|,)(?=[^"]|(")?)"?((?(1)[^"]*|[^,"]*))"?(?=,|$)

Regular expression visualization

Live Example

https://regex101.com/r/qR9nC2/1

Sample Text

10223,1600003B,Admin Officer,00000004,"Org Land, Inc.",ORGA03,ORGA03 HR & Admin

Sample Matches

MATCH 1
1.  ``
2.  [0-5]   `10223`
MATCH 2
1.  ``
2.  [6-14]  `1600003B`
MATCH 3
1.  ``
2.  [15-28] `Admin Officer`
MATCH 4
1.  ``
2.  [29-37] `00000004`
MATCH 5
1.  [38-39] `"`
2.  [39-53] `Org Land, Inc.`
MATCH 6
1.  ``
2.  [55-61] `ORGA03`
MATCH 7
1.  ``
2.  [62-79] `ORGA03 HR & Admin`
Community
  • 1
  • 1
Ro Yo Mi
  • 14,790
  • 5
  • 35
  • 43