Community
    • Login

    Removing characters in a certain position on the line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 837 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors