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 “”
-
Nothing special, just a pure typo.
I actually wanted to type the positive lookahead but for whatever reason … :-( -
(?<=colordiffuse=").+?(?=") -
Okay thanks, it works !
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