Adding extra data (one digit number,0)to all existing lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
smrasteg
Posts: 2
Joined: Tue Jul 26, 2011 11:00 am

Adding extra data (one digit number,0)to all existing lines

Post by smrasteg »

I would like to replace the following lines
load 30285 "1 " 0
load 12345 "1 " 0
.....................
....................
load xxxxx "1 " 0


to the below lines in my file using replace function in Texpad


load 30285 0 "1 " 0
load 12345 0 "1 " 0
.....................
....................
load xxxxx "0 1 " 0
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

I would use the following:
Find what: ^load ([0-9]{5})

Replace with: load \1 0

[X] Regular expression

Replace All
Note: There's a space after the '0' in the replacement expression.

This searches for all instances of a line starting with (^) the string 'load' followed by a space and 5 digits. It replaces it with 'load', the same 5 digits (\1 inserting the matching characters within the first set of brackets) and the extra '0' character.

Edit: A correction to the explanatory text.
Hope this helps.
Last edited by SteveH on Tue Jul 26, 2011 4:24 pm, edited 1 time in total.
Running TextPad 5.4 on Windows XP SP3 and on OS X 10.7 under VMWare or Crossover.
ben_josephs
Posts: 2457
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

SteveH's solution assumes you are using "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
The ^ in the regular expression matches at the beginnings of lines.

The expression /1 in the body of his message should be \1, as in the suggestion itself.
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

Whoops! :oops:

I've edited my post to fix these for consistency.
Running TextPad 5.4 on Windows XP SP3 and on OS X 10.7 under VMWare or Crossover.
smrasteg
Posts: 2
Joined: Tue Jul 26, 2011 11:00 am

Post by smrasteg »

Thanks. I had to replace with load \ \ 1 0 to have those five digit numbers after load.
ben_josephs
Posts: 2457
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Not in TextPad.
Post Reply