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
  • 421
  • 3
  • 11
  • 26

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,212
  • 4
  • 33
  • 41