K
Kev Jackson
given the following input:
"INSERT INTO PROJECT ( PROJECT_ID, PROJECTTITLE, PROJECTNO, PROJECTDATE,
CATEGORY, SECTOR, SECTION, DEPARTMENT, LOCATION, STATUS,
COMPLETIONSTATUS, CLIENT, TYPE ) VALUES ( 2319, 'SKIM PERPINDAHAN DAN
PERUMAHAN KAMPONG RATAIE, PERUMAHAN, KAMPONG RATAIE HOUSING CONTRACT H-3
(64 HOUSES)', 'AD520/0105', TO_Date( '01/01/1981 12:00:00 AM',
'MM/DD/YYYY HH:MI:SS AM'), '2', '2', 'T', 'G', 'D', 'D', NULL, NULL,
NULL, 3000000, 'Y', 2);"
How would you replace the commas embedded in the strings in the SQL?
I'm struggling with something like:
line.sub!(/(VALUES \(\s*\d+,\s*\'[\w\&\-\s]+)\',/,'\1')
to find the first 'string' after the VALUES and to attempt to remove any
commas. The problem is that the input can contain superfluous commas in
many places and I need to remove all commas in a quoted string (liek
gsub) before I can split the string.
I can't think of an easy way to achieve this, can any regexp/ruby expert
help me out?
Kev
"INSERT INTO PROJECT ( PROJECT_ID, PROJECTTITLE, PROJECTNO, PROJECTDATE,
CATEGORY, SECTOR, SECTION, DEPARTMENT, LOCATION, STATUS,
COMPLETIONSTATUS, CLIENT, TYPE ) VALUES ( 2319, 'SKIM PERPINDAHAN DAN
PERUMAHAN KAMPONG RATAIE, PERUMAHAN, KAMPONG RATAIE HOUSING CONTRACT H-3
(64 HOUSES)', 'AD520/0105', TO_Date( '01/01/1981 12:00:00 AM',
'MM/DD/YYYY HH:MI:SS AM'), '2', '2', 'T', 'G', 'D', 'D', NULL, NULL,
NULL, 3000000, 'Y', 2);"
How would you replace the commas embedded in the strings in the SQL?
I'm struggling with something like:
line.sub!(/(VALUES \(\s*\d+,\s*\'[\w\&\-\s]+)\',/,'\1')
to find the first 'string' after the VALUES and to attempt to remove any
commas. The problem is that the input can contain superfluous commas in
many places and I need to remove all commas in a quoted string (liek
gsub) before I can split the string.
I can't think of an easy way to achieve this, can any regexp/ruby expert
help me out?
Kev