Community
    • Login

    Search for 6 figure string but exclude certain strings

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 665 Views 1 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.
    • andy souterA Offline
      andy souter
      last edited by

      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.

      Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @andy souter
        last edited by

        @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 c2cf1a in that.
        I mean, crap, we could guess that you’re talking about the 303030 but…c’mon.

        andy souterA 1 Reply Last reply Reply Quote 0
        • andy souterA Offline
          andy souter @Alan Kilborn
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • CoisesC Online
            Coises @andy souter
            last edited by

            @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.

            andy souterA 1 Reply Last reply Reply Quote 1
            • andy souterA Offline
              andy souter @Coises
              last edited by

              @Coises Many Thanks I will report back with how I get on.

              andy souterA 1 Reply Last reply Reply Quote 0
              • andy souterA Offline
                andy souter @andy souter
                last edited by

                @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.

                1 Reply Last reply Reply Quote 1

                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