Community
    • Login

    Replace sets of numbers in a given position with 0

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 627 Views 2 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.
    • Fernando BernabeuF Offline
      Fernando Bernabeu
      last edited by

      Hello!
      I’ve been trying to look for a solution to this problem I have by using Regular Expressions, but I’ve come up empty.
      I have a pose file for a 3D model and the line I want to modify looks like this:

      Hips: 5.5 5.5 2.8 -0.0248 -0.0071 -0.0215 1 1 1

      The first three sets of numbers between spaces are rotation, the next three are position and the last three are size. The position sets of numbers can have up to 4 decimal numbers.
      What I want to do is replace the position sets of numbers with 0, so I could end up with a line like this:

      Hips: 5.5 5.5 2.8 0 0 0 1 1 1

      Would there be a way to specifically replace the 4th, 5th and 6th set of numbers between spaces with 0?
      Big TIA

      Neil SchipperN 1 Reply Last reply Reply Quote 0
      • Neil SchipperN Offline
        Neil Schipper @Fernando Bernabeu
        last edited by

        @fernando-bernabeu

        Here’s a solution with a very loose spec. It doesn’t care what the contents of the first 4+3=7 fields are, only that they are chunks of text separated by a single space.

        Ctl-h
        Fi: ^(?:(?:.*? ){4})\K((?:.*? ){3})
        Re: 0 0 0 <=== trailing space needed!
        Mode=regex; option box unchecked

        Then: Replace All

        What I want to do is replace the position sets of numbers with 0

        You don’t actually state that you want to do this for every occurrence in a file but that’s what I’ve assumed.

        Neil SchipperN 1 Reply Last reply Reply Quote 1
        • Neil SchipperN Offline
          Neil Schipper @Neil Schipper
          last edited by

          Here’s an expression with a somewhat tighter spec, in case file contains lines with different starting text you wish to ignore: ^Hips: (?:(?:.*? ){3})\K((?:.*? ){3})

          We can make it even tighter, such as validating that the other pieces consist of digits, maybe with decimal points, etc.

          Fernando BernabeuF 1 Reply Last reply Reply Quote 1
          • Fernando BernabeuF Offline
            Fernando Bernabeu @Neil Schipper
            last edited by

            @neil-schipper
            Thank you very much! That worked wonderfully!

            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