unable to replace

General questions about using TextPad

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

Post Reply
naxshio
Posts: 3
Joined: Wed Dec 15, 2010 5:50 pm

unable to replace

Post by naxshio »

please I have 15000 lines such as :
PCOMPG 1 -45.77 0. 0.
PCOMPG 2 -38.88 0. 0.
PCOMPG 3 -27.76 0. 0.
PCOMPG 4 -33.81 0. 0.

and so on....

I need to replace them by something like this:

PCOMPG 1 0. 0.
PCOMPG 2 0. 0.
PCOMPG 3 0. 0.
PCOMPG 4 0. 0.

repecting the alineations. How could I do it?
Thank you very much
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: (PCOMPG [0-9]) [^ ]+
Replace with: \1

[X] Regular expression

Replace All
naxshio
Posts: 3
Joined: Wed Dec 15, 2010 5:50 pm

Post by naxshio »

Hi Ben,

The issue is that I need to delete the second amount in the secuence of four and not to modify the place of the other numbers. When I write (PCOMPG [0-9]) [^ ]+ it doesn´t work.

Yhank you
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

The regular expression replacement I suggested does precisely what you asked for with the example you gave.

Did you select "Posix" regular expression syntax?
Did you select Regular expression?
Did you ensure there is no space at the end of the regular expression you copied from my message?
User avatar
woho
Posts: 100
Joined: Tue Sep 02, 2003 9:12 am
Location: Steyr/Austria
Contact:

Post by woho »

The issue is that I need to delete the second amount in the secuence of four and not to modify the place of the other numbers. When I write (PCOMPG [0-9]) [^ ]+ it doesn´t work.
if you mean that you would like to replace e.g -45.77 (6 characters) with blanks you can use

replace
(PCOMPG [0-9]) [^ ]+(.*)
with
\1 \2

note: there are 7 blanks between \1 and \2 => copy this but be careful not to have additional blanks at the end of the string

settings like Ben Josephs explained
Post Reply