Community
    • Login

    Replace help

    Scheduled Pinned Locked Moved General Discussion
    8 Posts 3 Posters 701 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.
    • Y MY Offline
      Y M
      last edited by

      Hello, I would like to replace multiple words… In a file I have a lot of colordiffuse=“[hexcolor]” with differents colors so colordiffuse=“FF545287” ; colordiffuse=“00FFFFFF” ,etc… And what I would like to to replace all of these lines by colordiffuse=“FF000000” so by a single color

      Is it possible ?

      1 Reply Last reply Reply Quote 0
      • EkopalypseE Offline
        Ekopalypse
        last edited by

        It looks like the colors are hexadecimal values and each are 8 digits. If this is the case, then you can use
        find what:(?<=colordiffuse=")[[:xdigit:]]{8}(?!>")
        replace with:FF000000
        and check regular expression checkbox

        PeterJonesP 1 Reply Last reply Reply Quote 4
        • Y MY Offline
          Y M
          last edited by

          Thanks !

          1 Reply Last reply Reply Quote 1
          • PeterJonesP Online
            PeterJones @Ekopalypse
            last edited by

            @Ekopalypse said in Replace help:

            find what:(?<=colordiffuse=")[[:xdigit:]]{8}(?!>")

            That works for the sample data, and the OP seems happy.

            But I’m curious: Why did you choose a negative lookahead (?!>") saying that the next two characters (after the 8 hex digits) aren’t >", rather than using a positive lookahead (?=") saying that the next character (after the 8 hex digits) must be "? If >" had been mentioned as an exception, I would understand using that, but as it is, that seems an interesting choice, and I wanted to see if there was any insight behind it, or just arbitrary on your part?

            1 Reply Last reply Reply Quote 1
            • Y MY Offline
              Y M
              last edited by

              And how to do that when it is colordiffuse=“[something]”, not only hexadecimal values but everything in the “”

              EkopalypseE 1 Reply Last reply Reply Quote 0
              • EkopalypseE Offline
                Ekopalypse
                last edited by Ekopalypse

                @PeterJones

                Nothing special, just a pure typo.
                I actually wanted to type the positive lookahead but for whatever reason … :-(

                1 Reply Last reply Reply Quote 1
                • EkopalypseE Offline
                  Ekopalypse @Y M
                  last edited by

                  @Y-M

                  (?<=colordiffuse=").+?(?=")

                  1 Reply Last reply Reply Quote 3
                  • Y MY Offline
                    Y M
                    last edited by

                    Okay thanks, it works !

                    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