[stackoverflow] [progress Openedge Abl] Regex For Parsing Strings With Quotes In Openedge...

Status
Not open for further replies.
P

Patrik

Guest
I have a data export from a Progress OpenEdge system that I want to parse in JavaScript. I would like to find all the fields of the export using a regular expression.

I have tried many things similar to this: /("[^"]*")|[^\s]+/g I have also tried to experiment with negative lookahead (?!"") but so far I have not succeeded.

A sample export output might look something similar to this:

12345 24,25 0 2015-06-30T14:53:14.891 "12345" "24,25" "0" "2015-06-30T14:53:14.891" "" yes no ? "String with ""quoted"" word" "String
with a multi
line string. "" <- Just a quote
" " This is the last value "
6789 35,36 0 2016-07-31T15:54:15.892 "6789" "35,36" "0" "2016-07-31T15:54:15.892" "" no yes ? "Just a simple string" ? ?


The fields are:

DEFINE TEMP-TABLE tt_test NO-UNDO
FIELD valueA AS INTEGER
FIELD valueB AS DECIMAL
FIELD valueC AS INTEGER
FIELD valueD AS DATETIME
FIELD valueE AS CHARACTER
FIELD valueF AS CHARACTER
FIELD valueG AS CHARACTER
FIELD valueH AS CHARACTER
FIELD valueI AS CHARACTER
FIELD valueJ AS LOGICAL
FIELD valueK AS LOGICAL
FIELD valueL AS LOGICAL
FIELD valueM AS CHARACTER
FIELD valueN AS CHARACTER
FIELD valueO AS CHARACTER
.


The export format is: All fields are separated by a space. Strings are contained within double-quote characters ("). If there is a quote in the string that is escaped by using two double-quote characters (""). If there is an empty string that is also two double-quote characters ( "" ) but with delimiter spaces around them.

The actual data types and the fact that this is a Progress system doesn't matter, it's just to give some context to my question.

So to summarize: How can I write a (JavaScript compatible) regular expression that successfully separates the different parts of the exported data while ignoring the escaped double-quotes in strings?

Continue reading...
 
Status
Not open for further replies.
Top