Community
    • Login

    Search for a multiple variable number

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 4 Posters 3.0k 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.
    • Paul CarfauP Offline
      Paul Carfau
      last edited by

      Hello,
      I need help to search a multiple variable text in a lots of lines.
      For example, I have this part who is always in the same format:

      / xxx xxx xxx 255 /
      / xx x xxx 255 /

      Or something like this, and i want to replace this by

      / 238 46 231 255 /

      How can I do ?

      Thanks for your help

      1 Reply Last reply Reply Quote 0
      • rinku singhR Offline
        rinku singh
        last edited by

        @Paul-Carfau said in Search for a multiple variable number:

        / xxx xxx xxx 255 /
        / xx x xxx 255 /
        Or something like this, and i want to replace this by
        / 238 46 231 255 /

        (?=/.*255 /)(/.*255 /=?)

        1 Reply Last reply Reply Quote 0
        • rinku singhR Offline
          rinku singh
          last edited by

          capture-20191106-080049.png

          1 Reply Last reply Reply Quote 0
          • Alan KilbornA Offline
            Alan Kilborn
            last edited by Alan Kilborn

            @Paul-Carfau

            I take it the x in your example are digits and the empty space is really simply a single space character?

            If so, then then searching for /\s\d{3}\s\d{3}\s\d{3}(?=\s255) and replacing with / 238 46 231 would work for your first example (set Regular expression mode).

            For your second example, do another replacement and tweak the first one slightly. Hint: Substitute different numbers inside the { and }.

            1 Reply Last reply Reply Quote 2
            • Paul CarfauP Offline
              Paul Carfau
              last edited by

              @gurikbal-singh @Alan-Kilborn
              I just realized by rereading my post that I forgot a precision. Your answers are correct, but my case is more complex because my lines are in this form:

              -38.2845993 41.9356995 -1.9463000 / 0.0000000 0.0000000 -1.0000000 / 0 0 0 255 / 0.0005000 0.4144570
              -38.2499008 41.5647011 6.4520898 / 0.5073535 0.0000000 0.8617381 / 22 30 34 255 / 0.9995010 0.4144000

              and I wish to change this way :

              -38.2845993 41.9356995 -1.9463000 / 0.0000000 0.0000000 -1.0000000 / 238 46 231 255 / 0.0005000 0.4144570
              -38.2499008 41.5647011 6.4520898 / 0.5073535 0.0000000 0.8617381 / 238 46 231 255 / 0.9995010 0.4144000

              And I do not find a solution despite having spent time on the forums …

              Michael VincentM 1 Reply Last reply Reply Quote 0
              • Michael VincentM Offline
                Michael Vincent @Paul Carfau
                last edited by

                @Paul-Carfau

                If the “precision” is just that the x’s can be “up-to” three digits, then use @Alan-Kilborn’s solution slightly modified:

                \s\d{1,3}\s\d{1,3}\s\d{1,3}(?=\s255)

                Cheers.

                1 Reply Last reply Reply Quote 1
                • Paul CarfauP Offline
                  Paul Carfau
                  last edited by

                  Your my god, thanks a lot man !

                  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