Replacing partial lines
-
I have a text file I’m editing with notepad++. It contains a list of skeleton positions for a 3D animation I am creating.
I need to replace everything in a whole line with something else, however I have multiple of these lines which have variations between them
For example:
23 -0.308254 -0.007814 0.307166 -0.110578 -0.404637 -2.460353 23 -0.769534 -0.467272 0.484695 -0.124567 -0.425321 -2.632211 23 -0.241245 -0.858433 0.008645 -0.331526 -0.865433 -2.987656 23 -0.308214 -0.526881 0.010142 -0.986212 -0.734622 -2.932811
I need to replace the content of these lines (which start with 23) and make them all into this:
23 -0.308254 -0.007814 0.307166 -0.110578 -0.404637 -2.460353
How do I do this?
-
It should be fairly simple as you only need the
23
to identify the line. So we have
Find:(^23).+
Replace:\1 -0.308254 -0.007814 0.307166 -0.110578 -0.404637 -2.460353
So it finds a line with
23
at the start. The.+
refers to all other characters on the line, and this is where it doesn’t care what those characters are (in your case numbers). Those characters (numbers in your case) are replaced with the new set of numbers. The\1
brings back the starting characters, namely23
.Terry
-
Hello, @donny-tee, and All,
If all your lines, beginning with the number
23
, follow the same template, that’s quite easy, my President !SEARCH
(?-s)^23\x20.+
REPLACE
23 -0.308254 -0.007814 0.307166 -0.110578 -0.404637 -2.460353
Notes :
-
First, the
(?-s)
modifier means that the regex dot symbol (.
) matches a single standard character, only ( and not an EOL char ) -
Then the part
^23\x20
matches the number23
, followed with a space character ( you may replace\x20
with a true space ) -
Finally, the part
.+
( or.{1,}
) matches the non-empty remaining of each line, beginning with the number23
Best Regards,
guy038
P.S.
It would be nice, President, if all your problems could be solved, in a similar way ;-)) Peoples and planet would just go on, living in peace !
-