Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Replace help

    General Discussion
    3
    8
    22
    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 M
      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
      • Ekopalypse
        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

        PeterJones 1 Reply Last reply Reply Quote 4
        • Y M
          Y M last edited by

          Thanks !

          1 Reply Last reply Reply Quote 1
          • PeterJones
            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 M
              Y M last edited by

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

              Ekopalypse 1 Reply Last reply Reply Quote 0
              • Ekopalypse
                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
                • Ekopalypse
                  Ekopalypse @Y M last edited by

                  @Y-M

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

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

                    Okay thanks, it works !

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors