Replace help

  • 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 ?

  • 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

  • Thanks !

  • @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?

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

  • @PeterJones

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

  • @Y-M


  • Okay thanks, it works !

Log in to reply