mrzippy
01-21-2004, 07:25 PM
Ack! I've been staring at this problem for way too long. Perhaps there is someone here who knows how to do this! :blush:
The answer can be in perl or a shell.. doesn't matter to me.
I need to basically find all occurences of a certain string pattern, and then replace them with a specific string. But the pattern I need to find is often "hidden" by line breaks, tabs, and various number of spaces.
For example:
Source file data: insert into "energydb".prty_status (audnum,aud_type,audref,
login,date_r,prt_status_code,prt_status_descr,status2,prt_sys_status,status_note1,
status_note2,create_user,update_user,update_datetime) values (0
,'D' ,NULL,USER ,TODAY ,old_prt_stat_rec.prt_status_code ,old_prt_stat_rec.prt_status_descr,
,old_prt_stat_rec.prt_sys_status ,old_prt_stat_rec.status_note1,
old_prt_stat_rec.status_note2 ,old_prt_stat_rec.create_user ,old_prt_stat_rec.update_user
,old_prt_stat_rec.update_datetime ));I need to find all occurences where there is:
1) A trailing comma at the end of the line, and
2) A comma at the start of the next line.
And once found, I need to add a "NULL" string of text after the first comma. So using the source data above, the data should look like this after processing: insert into "energydb".prty_status (audnum,aud_type,audref,
login,date_r,prt_status_code,prt_status_descr,status2,prt_sys_status,status_note1,
status_note2,create_user,update_user,update_datetime) values (0
,'D' ,NULL,USER ,TODAY ,old_prt_stat_rec.prt_status_code ,old_prt_stat_rec.prt_status_descr, NULL
,old_prt_stat_rec.prt_sys_status ,old_prt_stat_rec.status_note1,
old_prt_stat_rec.status_note2 ,old_prt_stat_rec.create_user ,old_prt_stat_rec.update_user
,old_prt_stat_rec.update_datetime ));
Now the problem is that there may be an unknown number of blank spaces, tabs, and line breaks between the two commas.
It doesn't matter to me if the processing is done in shell or perl.
Anyone know how to do this? Please? :D
The answer can be in perl or a shell.. doesn't matter to me.
I need to basically find all occurences of a certain string pattern, and then replace them with a specific string. But the pattern I need to find is often "hidden" by line breaks, tabs, and various number of spaces.
For example:
Source file data: insert into "energydb".prty_status (audnum,aud_type,audref,
login,date_r,prt_status_code,prt_status_descr,status2,prt_sys_status,status_note1,
status_note2,create_user,update_user,update_datetime) values (0
,'D' ,NULL,USER ,TODAY ,old_prt_stat_rec.prt_status_code ,old_prt_stat_rec.prt_status_descr,
,old_prt_stat_rec.prt_sys_status ,old_prt_stat_rec.status_note1,
old_prt_stat_rec.status_note2 ,old_prt_stat_rec.create_user ,old_prt_stat_rec.update_user
,old_prt_stat_rec.update_datetime ));I need to find all occurences where there is:
1) A trailing comma at the end of the line, and
2) A comma at the start of the next line.
And once found, I need to add a "NULL" string of text after the first comma. So using the source data above, the data should look like this after processing: insert into "energydb".prty_status (audnum,aud_type,audref,
login,date_r,prt_status_code,prt_status_descr,status2,prt_sys_status,status_note1,
status_note2,create_user,update_user,update_datetime) values (0
,'D' ,NULL,USER ,TODAY ,old_prt_stat_rec.prt_status_code ,old_prt_stat_rec.prt_status_descr, NULL
,old_prt_stat_rec.prt_sys_status ,old_prt_stat_rec.status_note1,
old_prt_stat_rec.status_note2 ,old_prt_stat_rec.create_user ,old_prt_stat_rec.update_user
,old_prt_stat_rec.update_datetime ));
Now the problem is that there may be an unknown number of blank spaces, tabs, and line breaks between the two commas.
It doesn't matter to me if the processing is done in shell or perl.
Anyone know how to do this? Please? :D
