Page 1 of 1

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

Posted: Tue Jul 26, 2011 11:17 am
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

Posted: Tue Jul 26, 2011 11:30 am
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.

Posted: Tue Jul 26, 2011 12:20 pm
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.

Posted: Tue Jul 26, 2011 4:23 pm
by SteveH
Whoops! :oops:

I've edited my post to fix these for consistency.

Posted: Wed Jul 27, 2011 2:49 pm
by smrasteg
Thanks. I had to replace with load \ \ 1 0 to have those five digit numbers after load.

Posted: Wed Jul 27, 2011 3:35 pm
by ben_josephs
Not in TextPad.