Hi Everybody,
I have a large textfile with a lot of rows. Each row contains one number and comma.
What I have to do now is that I have to replace the comma every 999th row with a String (e.g. test).
Is there a possibilty to do this automatically or do I have to do it manually?
Regards
Replace a character every 999th row
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
You can't do this in TextPad with regular expressions because of weaknesses in its regular expression engine. (You can't put a \n inside a repetition, and the regular expression appears to be restricted to 1023 characters, so that you can't have more than 255 repetitions of .*\n in it.)
Recording a macro to do it would be tedious in the extreme. You can solve part of the problem by recording a macro that moves down a line, and using Macros | Multi-play... to repeat it 999 times, but this doesn't really help very much.
This is another case that demonstrates the need for upgrading the regex engine or providing a scripting capability, or, preferably, both.
Recording a macro to do it would be tedious in the extreme. You can solve part of the problem by recording a macro that moves down a line, and using Macros | Multi-play... to repeat it 999 times, but this doesn't really help very much.
This is another case that demonstrates the need for upgrading the regex engine or providing a scripting capability, or, preferably, both.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
I think a macro combination could combine the movement and the replacement by using two macros.
Macro1 - Set to run 999 times.
Go to position at beginning of the line.
Press Down key
Macro2 - Set to run once.
Call Macro1
Search/Replace the comma.
Go to position to run macro1 again.
Repeat running Macro2 as many times as needed to process all lines.
=========================
I have not tried this, but I seem to recall that you can run a macro that calls another one. If not, then this will not work.
Macro1 - Set to run 999 times.
Go to position at beginning of the line.
Press Down key
Macro2 - Set to run once.
Call Macro1
Search/Replace the comma.
Go to position to run macro1 again.
Repeat running Macro2 as many times as needed to process all lines.
=========================
I have not tried this, but I seem to recall that you can run a macro that calls another one. If not, then this will not work.
Hope this was helpful.............good luck,
Bob
Bob
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
- MudGuard
- Posts: 1295
- Joined: Sun Mar 02, 2003 10:15 pm
- Location: Munich, Germany
- Contact:
What you believe isben_josephs wrote:I don't believe that one macro can call another one.
- irrelevant ;-)
- in this case wrong
The problem I see is that "Multiplay" is disabled during macro recording, so it's impossible to create a macro that runs Bob's Macro1 999 times and then runs Bob's Macro2 ...
And a macro does only offer "Once", "Repeat thru Selection" and "Repeat to end of file" as storable repeat counters, not a fixed number ...
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
You're right on both counts.MudGuard wrote:What you believe is
- irrelevant
- in this case wrong
I should avoid making statements about TextPad's macros because, as is plain, I'm not an expert on them. I rarely use them as (1) they're so weak and (2) you can't edit them.