Page 1 of 1
unable to replace
Posted: Wed Dec 15, 2010 6:03 pm
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
Posted: Wed Dec 15, 2010 7:37 pm
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
Posted: Thu Dec 16, 2010 8:33 am
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
Posted: Thu Dec 16, 2010 10:52 am
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?
Posted: Thu Dec 16, 2010 12:35 pm
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