• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1365
  • 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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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