• Login
Community
  • Login

Search for a multiple variable number

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 4 Posters 2.3k 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.
  • P
    Paul Carfau
    last edited by Nov 5, 2019, 10:29 PM

    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
    • R
      rinku singh
      last edited by Nov 6, 2019, 2:26 AM

      @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
      • R
        rinku singh
        last edited by Nov 6, 2019, 2:32 AM

        capture-20191106-080049.png

        1 Reply Last reply Reply Quote 0
        • A
          Alan Kilborn
          last edited by Alan Kilborn Nov 6, 2019, 1:25 PM Nov 6, 2019, 1:25 PM

          @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
          • P
            Paul Carfau
            last edited by Nov 6, 2019, 5:27 PM

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

            M 1 Reply Last reply Nov 6, 2019, 5:33 PM Reply Quote 0
            • M
              Michael Vincent @Paul Carfau
              last edited by Nov 6, 2019, 5:33 PM

              @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
              • P
                Paul Carfau
                last edited by Nov 6, 2019, 6:58 PM

                Your my god, thanks a lot man !

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