Community
    • Login

    Removing characters in a certain position on the line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 564 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DIMITRIOS STAMATIOUD
      DIMITRIOS STAMATIOU
      last edited by

      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.

      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @DIMITRIOS STAMATIOU
        last edited by

        @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)

        DIMITRIOS STAMATIOUD 1 Reply Last reply Reply Quote 3
        • DIMITRIOS STAMATIOUD
          DIMITRIOS STAMATIOU @Mark Olson
          last edited by

          @Mark-Olson,
          Thank you so much, you saved me from many hours of work.
          Much Appreciated.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors