Search for 6 figure string but exclude certain strings
-
I have an application that produces objects files. Each object has a .mtl text file. This .mtl files contains a 6 figure hexcode defining a colour. The application generates random colour hexcodes ie. c2cf1a. Therefore I want find and change all hexcodes with numbers in them to a defined 6 figure string.
An example line of text - map_Kd baked_303030_brick.dds
Therefore I want to Find all instances of 6 figure string with numbers in it i.e c2cf1af
and replace with a defined string i.e. aaaaaa
I am tring to use Notepad++ to do this but finding the regex expressions hard to understand.
Having found the solution using \w(6)_ as the 6 figure string always ends with an underscore. this works very well however I now want to extend the search to provide what I originally wanted i.e. the 6 figure hex code follwed by underscore, but now to allow the search to ignore any of the following:
aaaaaa bbbbbb cccccc dddddd eeeeee ffffff
Is there a fairly easy solution to this?
Thank you.
-
@andy-souter said in Search for 6 figure string but exclude certain strings:
An example line of text - map_Kd baked_303030_brick.dds
I see no
c2cf1ain that.
I mean, crap, we could guess that you’re talking about the303030but…c’mon. -
@Alan-Kilborn It was what I said, an example line of text. The hex codes that I want to indentify are any 6 figure combination of 0 to 7 and a to f. The example solution I gave of \w(6)_ does what I want and identifies all the 6 figure hex code strings but I want to exclude the strings aaaaaa bbbbbb cccccc dddddd eeeeee and ffffff.
-
@andy-souter said in Search for 6 figure string but exclude certain strings:
ignore any of the following:
aaaaaa bbbbbb cccccc dddddd eeeeee ffffff
Is there a fairly easy solution to this?
There is. Use a negative look-ahead:
(?!aaaaaa|bbbbbb|cccccc|dddddd|eeeeee|ffffff)I’ll leave it as an exercise for you to read and understand the documentation I linked — when you do, you’ll know how to add that to the expression you already have.
-
@Coises Many Thanks I will report back with how I get on.
-
@andy-souter Yes, found out how to make it work. Excludes the strings i want excluded, but getting new ones not excluded that I did not expect. But I now have a way forward. Thanks for your help.
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