Removing characters in a certain position on the line
-
Hello Guys,
I have alot of text files with a set of coordinates and i want to remove in all of them the z coordinate like in the example below:
{Position 987.2 2263.3 -12.99}
and then remove -12.99 so it is like this
{Position 987.2 2263.3}Basically to delete everything after the third " " character and before the }
Thank you for your replies.
-
@DIMITRIOS-STAMATIOU said in Removing characters in a certain position on the line:
{Position 987.2 2263.3 -12.99}
Use the find/replace form (Ctrl+H with default keybindings)
Find what:(?-i)({Position(?: [+-]?\d+(?:\.\d+)?){2})(?: [+-]?\d+(?:\.\d+)?)}
Replace with:${1}}
Search Mode:Regular expression
I replaced
{Position -33.474 -6.304 -5.288} {Position -38.143 25.527 -16.232} {Position 31.708 32.052 4.161} {Position 2.254 36.771 12.793} {Position -28.217 27.783 -29.420}
with
{Position -33.474 -6.304} {Position -38.143 25.527} {Position 31.708 32.052} {Position 2.254 36.771} {Position -28.217 27.783}
Note that this will not work on numbers with scientific notation (like
3e1
) or numbers with leading decimal points (like.75
) -
@Mark-Olson,
Thank you so much, you saved me from many hours of work.
Much Appreciated.