[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1322
  • Last Modified:

Insert a string in a text file every 1000 rows using UltraEdit

Hello,

I have a text file with one million PL/SQL commands:

INSERT INTO GOOFY VALUES (1);
INSERT INTO GOOFY VALUES (2);
INSERT INTO GOOFY VALUES (3);
...........
INSERT INTO GOOFY VALUES (1000000);

Using UltraEdit, I would like to insert a row containing only:

COMMIT;

every 1000 rows: how could I achieve this?
0
hc2342uhxx3vw36x96hq
Asked:
hc2342uhxx3vw36x96hq
  • 3
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
Try this
var str = "INSERT INTO GOOFY VALUES (3);INSERT INTO GOOFY VALUES (3);";
var re = new RegExp("(INSERT\sINTO\sGOOFY\sVALUES\s\([0-9]*\);\n){2}", "g");
var myArray = str.replace(re,"(INSERT\sINTO\sGOOFY\sVALUES\s\([0-9]*\);\n){2}\rCommit;" );

or

var myArray = str.replace(/(INSERT\sINTO\sGOOFY\sVALUES\s\([0-9]*\);\n){2}/g,
"(INSERT\sINTO\sGOOFY\sVALUES\s\([0-9]*\);\n){2}\rCommit;")
0
 
käµfm³d 👽Commented:
Try the following pattern. Make sure you have The "Regular Expresson" checkbox marked and under the Advanced button, select the Perl radio button under "Regular Expression Engine".

    ((.+?\r\n){100})

Your replace text should be:

    \1COMMIT;\n
untitled.JPG
0
 
käµfm³d 👽Commented:
Change 100 to 1000 in the previous post.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
hc2342uhxx3vw36x96hqAuthor Commented:
Your solution with screenshot attached is PERFECT!  Thank you very much for your competence and for your fast help!! ;-)
0
 
käµfm³d 👽Commented:
LOL!  It was no trouble. I actually got curious about UE's functionality when I read your post, so it was of benefit to me as well :)
0
 
hc2342uhxx3vw36x96hqAuthor Commented:
Programming in PL/SQL, I usually produce text files with 1,000,000 statements, so your technique using UltraEdit will be useful for me ;-)

Thank you again ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now