Community
    • Login

    Search with content exclusion

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    19 Posts 5 Posters 3.1k Views
    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.
    • Peter CohenP
      Peter Cohen
      last edited by

      Hello astrofista,
      Thanks for putting me on the path to a solution.
      However, using your expression, I did not get the result I want.
      Using the table below, I ONLY want to find line 2 & 4.
      Using RESULTVALUE=(?=") gets me nothing.
      Using RESULTVALUE=(?=0) gets me all the zero (0) values.
      Is there a way to specify (?=Not 0)

      RESULTVALUE=0
      RESULTVALUE=5
      RESULTVALUE=0
      RESULTVALUE=7
      RESULTVALUE=0

      Alan KilbornA astrosofistaA 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Peter Cohen
        last edited by

        @Peter-Cohen

        For “not zero”, try (?!0), so RESULTVALUE=(?!0) for your need.

        1 Reply Last reply Reply Quote 1
        • astrosofistaA
          astrosofista @Peter Cohen
          last edited by

          Hi @Peter-Cohen

          You’re welcome. My regex says: match every RESULTVALUE= that is followed by a quote ", as I read your example. However it seems that I misunderstood your needs.

          Try this other regex instead:

          RESULTVALUE=(?!0")
          

          It will match every ‘RESULTVALUE=’ that is not followed by 0".

          Hope it’s fine now.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @astrosofista
            last edited by

            @astrosofista

            I really don’t think that " enter into the OP’s need at all.
            He was just using the quotes because he’s familiar with doing it when using grep, I think.

            astrosofistaA 1 Reply Last reply Reply Quote 1
            • astrosofistaA
              astrosofista @Alan Kilborn
              last edited by astrosofista

              @Alan-Kilborn

              Good point :)

              @Peter-Cohen

              Remove the quote from my regex if not needed.

              Alan KilbornA 1 Reply Last reply Reply Quote 2
              • Alan KilbornA
                Alan Kilborn @astrosofista
                last edited by

                @astrosofista said in Search with content exclusion:

                Remove the quote from my regex if not needed.

                At which point, doesn’t it become the same as MY regex? ;-)

                1 Reply Last reply Reply Quote 0
                • Peter CohenP
                  Peter Cohen
                  last edited by

                  Gentlemen,
                  Thank you very much, RESULTVALUE=(?!0) did the trick.
                  Sorry if I confused you - I was even more confused.
                  This is definitely very powerful and useful (and tricky).

                  1 Reply Last reply Reply Quote 1
                  • Peter CohenP
                    Peter Cohen
                    last edited by

                    BTW - would it be impertinent from me to ask WHY/HOW this works?
                    I am trying to decipher (?!0) and - admittedly - don’t understand what it actually stands for.
                    Interestingly, I changed one of the lines to:
                    RESULTVALUE=090 and now the search doesn’t find it, I suspect because it starts with a 0.

                    Alan KilbornA astrosofistaA 2 Replies Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @Peter Cohen
                      last edited by Alan Kilborn

                      @Peter-Cohen said in Search with content exclusion:

                      would it be impertinent from me to ask WHY/HOW this works?

                      Of course not.

                      The construct (?!…) is a negative lookahead assertion.
                      It means that at the current position, for there to be a composite match, whatever ... is, cannot be a match for the data (or the overall match fails).

                      Traditionally, in computer science, ! means “not”.

                      So in an Englishy way, the expression RESULTVALUE=(?!0) means:

                      match RESULTVALUE= literally, and then insist that the next character is not 0 for a match to be possible.

                      But the way (?!0) is used here, it precludes 090 from matching (the search stops trying to match at the first 0).

                      If something is unclear, post again.

                      You can find many more details about the concepts begun here, in THIS thread.

                      1 Reply Last reply Reply Quote 3
                      • Peter CohenP
                        Peter Cohen
                        last edited by

                        Hello @Alan-Kilborn - going through a crash course here.
                        BTW - I used to be a computer programmer in a previous life, but this, definitely, is new territory for me :-|
                        I will definitely have to read up on this - thanks for the link.

                        1 Reply Last reply Reply Quote 2
                        • astrosofistaA
                          astrosofista @Peter Cohen
                          last edited by

                          @Peter-Cohen said in Search with content exclusion:

                          RESULTVALUE=090 and now the search doesn’t find it, I suspect because it starts with a 0.

                          You got it, that’s correct.

                          However that doesn’t mean that you cannot match a number that starts with a 0. The following regex will match RESULTVALUE=090 but not RESULTVALUE=0 or RESULTVALUE=", that is, when RESULTVALUE= is followed by any other symbol than a number:

                          RESULTVALUE=(?!0\D)(?=\d)
                          

                          Hope this helps.

                          1 Reply Last reply Reply Quote 0
                          • Peter CohenP
                            Peter Cohen
                            last edited by

                            Holy cow - let me play with this - thanks.

                            1 Reply Last reply Reply Quote 0
                            • guy038G
                              guy038
                              last edited by guy038

                              Hi, @peter-cohen, @astrosofista, @alan-kilborn and All,

                              Let’s imagine that we want to search for any integer or floating decimal number, different of any zero syntax, when it follows the RESULTVALUE= string, with this exact case. Then a possible regex, expressed with the free-spacing mode ( (?x) ) could be :

                              (?x-i)  RESULTVALUE=  \K  [+-]?  (  (?! 0 \. 0? \D | 0 [^\d.] )  \d+  ( \. \d* )?  |  \.  (?! 0 \D ) \d+  )
                              

                              • Paste the text, below, in a N++ new tab
                                  RESULTVALUE=              No               ResultValue=              No                                      
                                  RESULTVALUE=.             No               ResultValue=.             No                 .               No   
                                                                                                                                               
                                  RESULTVALUE=,             No               ResultValue=,             No                 ,               No   
                                  RESULTVALUE=ABC           No               ResultValue=ABC           No                 ABC             No   
                                                                                                                                               
                                  RESULTVALUE=0             No               ResultValue=0             No                 0               No   
                                  RESULTVALUE=-0            No               ResultValue=-0            No                 -0              No   
                                  RESULTVALUE=+0            No               ResultValue=+0            No                 +0              No   
                                                                                                                                               
                                  RESULTVALUE=.0            No               ResultValue=.0            No                 .0              No   
                                  RESULTVALUE=-.0           No               ResultValue=-.0           No                 -.0             No   
                                  RESULTVALUE=+.0           No               ResultValue=+.0           No                 +.0             No   
                                                                                                                                               
                                  RESULTVALUE=0.            No               ResultValue=0.            No                 0.              No   
                                  RESULTVALUE=+0.           No               ResultValue=+0.           No                 +0.             No   
                                  RESULTVALUE=-0.           No               ResultValue=-0.           No                 -0.             No   
                                                                                                                                               
                                  RESULTVALUE=0.0           No               ResultValue=0.0           No                 0.0             No   
                                  RESULTVALUE=+0.0          No               ResultValue=+0.0          No                 +0.0            No   
                                  RESULTVALUE=-0.0          No               ResultValue=-0.0          No                 -0.0            No   
                                                                                                                                               
                                  RESULTVALUE=0.00120       Yes              ResultValue=0.00120       No / Yes           0.00120         No   
                                  RESULTVALUE=0.00123       Yes              ResultValue=0.00123       No / Yes           0.00123         No   
                                  RESULTVALUE=0.12300       Yes              ResultValue=0.12300       No / Yes           0.12300         No   
                                  RESULTVALUE=0.42          Yes              ResultValue=0.42          No / Yes           0.42            No   
                                  RESULTVALUE=.71           Yes              ResultValue=.71           No / Yes           .71             No   
                                  RESULTVALUE=2             Yes              ResultValue=2             No / Yes           2               No   
                                  RESULTVALUE=5.            Yes              ResultValue=5.            No / Yes           5.              No   
                                  RESULTVALUE=6.8           Yes              ResultValue=6.8           No / Yes           6.8             No   
                                  RESULTVALUE=007.1         Yes              ResultValue=007.1         No / Yes           007.1           No   
                                  RESULTVALUE=091           Yes              ResultValue=091           No / Yes           091             No   
                                                                                                                                               
                                  RESULTVALUE=+0.00120      Yes              ResultValue=+0.00120      No / Yes           +0.00120        No   
                                  RESULTVALUE=+0.00123      Yes              ResultValue=+0.00123      No / Yes           +0.00123        No   
                                  RESULTVALUE=+0.12300      Yes              ResultValue=+0.12300      No / Yes           +0.12300        No   
                                  RESULTVALUE=+0.42         Yes              ResultValue=+0.42         No / Yes           +0.42           No   
                                  RESULTVALUE=+.71          Yes              ResultValue=+.71          No / Yes           +.71            No   
                                  RESULTVALUE=+2            Yes              ResultValue=+2            No / Yes           +2              No   
                                  RESULTVALUE=+5.           Yes              ResultValue=+5.           No / Yes           +5.             No   
                                  RESULTVALUE=+6.8          Yes              ResultValue=+6.8          No / Yes           +6.8            No   
                                  RESULTVALUE=+007.1        Yes              ResultValue=+007.1        No / Yes           +007.1          No   
                                  RESULTVALUE=+091          Yes              ResultValue=+091          No / Yes           +091            No   
                                                                                                                                               
                                  RESULTVALUE=-0.00120      Yes              ResultValue=-0.00120      No / Yes           -0.00120        No   
                                  RESULTVALUE=-0.00123      Yes              ResultValue=-0.00123      No / Yes           -0.00123        No   
                                  RESULTVALUE=-0.12300      Yes              ResultValue=-0.12300      No / Yes           -0.12300        No   
                                  RESULTVALUE=-0.42         Yes              ResultValue=-0.42         No / Yes           -0.42           No   
                                  RESULTVALUE=-.71          Yes              ResultValue=-.71          No / Yes           -.71            No   
                                  RESULTVALUE=-2            Yes              ResultValue=-2            No / Yes           -2              No   
                                  RESULTVALUE=-5.           Yes              ResultValue=-5.           No / Yes           -5.             No   
                                  RESULTVALUE=-6.8          Yes              ResultValue=-6.8          No / Yes           -6.8            No   
                                  RESULTVALUE=-007.1        Yes              ResultValue=-007.1        No / Yes           -007.1          No   
                                  RESULTVALUE=-091          Yes              ResultValue=-091          No / Yes           -091            No   
                              

                              • Open the Mark dialog ( Ctrl + M )

                                • SEARCH (?-i)RESULTVALUE=\K[+-]?((?!0\.0?\D|0[^\d.])\d+(\.\d*)?|\.(?!0\D)\d+)

                                • Tick the Purge for each search option

                                • Tick the Wrap around option

                                • Select the Regular expression search mode

                                • Click on the Mark All button

                              => Only numbers, located after the RESULTVALUE= string, with this case, and strictly different from 0, should be highlighted in red

                              Now, if you modify the regex as (?i)RESULTVALUE=\K[+-]?((?!0\.0?\D|0[^\d.])\d+(\.\d*)?|\.(?!0\D)\d+), the numbers, located after the string ResultValue= are also highlighted !


                              Peter, this example is simply provided to show the powerful of regular expressions. Of course, you cannot fully understand that example, by now. Just execute the regexes to get the results and, from the @alan-kilborn’s link, try to learn the basic regex features !

                              Best Regards,

                              guy038

                              1 Reply Last reply Reply Quote 1
                              • Peter CohenP
                                Peter Cohen
                                last edited by

                                Good afternoon @Folks,
                                I am off to regex school, although, admittedly, these last expressions do make my head spin @Exorcist :-)

                                BeatBullzB 1 Reply Last reply Reply Quote 1
                                • BeatBullzB
                                  BeatBullz @Peter Cohen
                                  last edited by BeatBullz

                                  @guy038
                                  So i’m using this one actually:

                                  (?-i)ShaderMillDataHash" value="\K[±]?((?!0.0?\D|0[^\d.])\d+(.\d*)?|.(?!0\D)\d+)

                                  like all values behind ShaderMillDataHash except 0:
                                  ShaderMillDataHash" value="

                                  But i need to find another value in the same files.

                                  Two generally to split the search results.

                                  All search results with UBERSHADER.SHADER.BIN in the files + the regex from above
                                  And all search results with SHADERMILLUBER.SHADER.BIN + regex from above

                                  I tried
                                  (?-i)(UBERSHADER.SHADER.BIN|ShaderMillDataHash" value=")\K[±]?((?!0.0?\D|0[^\d.])\d+(.\d*)?|.(?!0\D)\d+)

                                  (?-i)SHADERMILLUBER.SHADER.BIN|ShaderMillDataHash" value="\K[±]?((?!0.0?\D|0[^\d.])\d+(.\d*)?|.(?!0\D)\d+)

                                  and it doesnt even use the first search parameter *SHADER.BIN

                                  So how do i do this?

                                  1 Reply Last reply Reply Quote 0
                                  • guy038G
                                    guy038
                                    last edited by guy038

                                    Hello, @beatbullz and All,

                                    So, after more than three years, and with an other user-name, you’re asking me for some modifications regarding my old provided regex. Your approach is very unusual ;-))


                                    Anyway, I’ll try to help you !

                                    First, I slightly improved my previous regex to this syntax, using the free-spacing mode (?x) :

                                    SEARCH / MARK (?x-i) RESULTVALUE = \K [+-]? (?: (?! 0+ ( \. 0* )? [^\d.] ) \d+ ( \. \d* )? | \. (?! 0+ \D ) \d+ )


                                    Thus, in order to find, independently, the lines containing the string :

                                    • ShaderMillDataHash" value="

                                    Or

                                    • SHADERMILLUBER.SHADER.BIN=

                                    Or

                                    • UBERSHADER.SHADER.BIN=

                                    Use the regex A , B or C, below :

                                    Regex A : (?-i)ShaderMillDataHash" value="\K[+-]?(?:(?!0+(\.0*)?[^\d.])\d+(\.\d*)?|\.(?!0+\D)\d+)

                                    Regex B : (?-i)SHADERMILLUBER.SHADER.BIN=\K[+-]?(?:(?!0+(\.0*)?[^\d.])\d+(\.\d*)?|\.(?!0+\D)\d+)

                                    Regex C : (?-i)UBERSHADER.SHADER.BIN=\K[+-]?(?:(?!0+(\.0*)?[^\d.])\d+(\.\d*)?|\.(?!0+\D)\d+)

                                    Now, if you prefer to search for all the lines, at the same time, use the regex D below :

                                    Regex D : (?-i)(?:ShaderMillDataHash" value="|SHADERMILLUBER.SHADER.BIN=|UBERSHADER.SHADER.BIN=)\K[+-]?(?:(?!0+(\.0*)?[^\d.])\d+(\.\d*)?|\.(?!0+\D)\d+)


                                    You can test all these regexes against the text below :

                                    
                                      FORBIDEN cases :
                                    
                                        ShaderMillDataHash" value="              No             SHADERMILLUBER.SHADER.BIN=              No            UBERSHADER.SHADER.BIN=              No
                                        ShaderMillDataHash" value=".             No             SHADERMILLUBER.SHADER.BIN=.             No            UBERSHADER.SHADER.BIN=.             No
                                        ShaderMillDataHash" value=",             No             SHADERMILLUBER.SHADER.BIN=,             No            UBERSHADER.SHADER.BIN=,             No
                                    
                                        ShaderMillDataHash" value="ABC           No             SHADERMILLUBER.SHADER.BIN=ABC           No            UBERSHADER.SHADER.BIN=ABC           No
                                        ShaderMillDataHash" value="0A123         No             SHADERMILLUBER.SHADER.BIN=0A123         No            UBERSHADER.SHADER.BIN=0A123         No
                                        ShaderMillDataHash" value="0000Z123      No             SHADERMILLUBER.SHADER.BIN=0000Z123      No            UBERSHADER.SHADER.BIN=0000Z123      No
                                        ShaderMillDataHash" value="0.Z123        No             SHADERMILLUBER.SHADER.BIN=0.Z123        No            UBERSHADER.SHADER.BIN=0.Z123        No
                                        ShaderMillDataHash" value="0.ABC123      No             SHADERMILLUBER.SHADER.BIN=0.ABC123      No            UBERSHADER.SHADER.BIN=0.ABC123      No
                                        ShaderMillDataHash" value="000.DEF1      No             SHADERMILLUBER.SHADER.BIN=000.DEF1      No            UBERSHADER.SHADER.BIN=000.DEF1      No
                                    
                                        ShaderMillDataHash" value="0             No             SHADERMILLUBER.SHADER.BIN=0             No            UBERSHADER.SHADER.BIN=0             No
                                        ShaderMillDataHash" value=".0            No             SHADERMILLUBER.SHADER.BIN=.0            No            UBERSHADER.SHADER.BIN=.0            No
                                        ShaderMillDataHash" value="0.            No             SHADERMILLUBER.SHADER.BIN=0.            No            UBERSHADER.SHADER.BIN=0.            No
                                        ShaderMillDataHash" value="0.0           No             SHADERMILLUBER.SHADER.BIN=0.0           No            UBERSHADER.SHADER.BIN=0.0           No
                                        ShaderMillDataHash" value="00000         No             SHADERMILLUBER.SHADER.BIN=00000         No            UBERSHADER.SHADER.BIN=00000         No
                                        ShaderMillDataHash" value="0.000         No             SHADERMILLUBER.SHADER.BIN=0.000         No            UBERSHADER.SHADER.BIN=0.000         No
                                        ShaderMillDataHash" value="00.000        No             SHADERMILLUBER.SHADER.BIN=00.000        No            UBERSHADER.SHADER.BIN=00.000        No
                                        ShaderMillDataHash" value="0.            No             SHADERMILLUBER.SHADER.BIN=0.            No            UBERSHADER.SHADER.BIN=0.            No
                                        ShaderMillDataHash" value="00.           No             SHADERMILLUBER.SHADER.BIN=00.           No            UBERSHADER.SHADER.BIN=00.           No
                                        ShaderMillDataHash" value=".000          No             SHADERMILLUBER.SHADER.BIN=.000          No            UBERSHADER.SHADER.BIN=.000          No
                                    
                                    
                                      ALLOWED cases :
                                    
                                        ShaderMillDataHash" value="0.00120       Yes            SHADERMILLUBER.SHADER.BIN=0.00120       Yes            UBERSHADER.SHADER.BIN=0.00120       Yes
                                        ShaderMillDataHash" value="0.00123       Yes            SHADERMILLUBER.SHADER.BIN=0.00123       Yes            UBERSHADER.SHADER.BIN=0.00123       Yes
                                        ShaderMillDataHash" value="0.12300       Yes            SHADERMILLUBER.SHADER.BIN=0.12300       Yes            UBERSHADER.SHADER.BIN=0.12300       Yes
                                        ShaderMillDataHash" value="0.42          Yes            SHADERMILLUBER.SHADER.BIN=0.42          Yes            UBERSHADER.SHADER.BIN=0.42          Yes
                                        ShaderMillDataHash" value=".71           Yes            SHADERMILLUBER.SHADER.BIN=.71           Yes            UBERSHADER.SHADER.BIN=.71           Yes
                                        ShaderMillDataHash" value=".00954        Yes            SHADERMILLUBER.SHADER.BIN=.00954        Yes            UBERSHADER.SHADER.BIN=.00954        Yes
                                        ShaderMillDataHash" value="2             Yes            SHADERMILLUBER.SHADER.BIN=2             Yes            UBERSHADER.SHADER.BIN=2             Yes
                                        ShaderMillDataHash" value="5.            Yes            SHADERMILLUBER.SHADER.BIN=5.            Yes            UBERSHADER.SHADER.BIN=5.            Yes
                                        ShaderMillDataHash" value="6.8           Yes            SHADERMILLUBER.SHADER.BIN=6.8           Yes            UBERSHADER.SHADER.BIN=6.8           Yes
                                        ShaderMillDataHash" value="007.1         Yes            SHADERMILLUBER.SHADER.BIN=007.1         Yes            UBERSHADER.SHADER.BIN=007.1         Yes
                                        ShaderMillDataHash" value="091           Yes            SHADERMILLUBER.SHADER.BIN=091           Yes            UBERSHADER.SHADER.BIN=091           Yes
                                        ShaderMillDataHash" value="8000          Yes            SHADERMILLUBER.SHADER.BIN=8000          Yes            UBERSHADER.SHADER.BIN=8000          Yes
                                        ShaderMillDataHash" value="9.000         Yes            SHADERMILLUBER.SHADER.BIN=9.000         Yes            UBERSHADER.SHADER.BIN=9.000         Yes
                                        ShaderMillDataHash" value="0.756000      Yes            SHADERMILLUBER.SHADER.BIN=0.756000      Yes            UBERSHADER.SHADER.BIN=0.756000      Yes
                                    
                                    

                                    Best Regards,

                                    guy038

                                    BeatBullzB 1 Reply Last reply Reply Quote 0
                                    • BeatBullzB
                                      BeatBullz @guy038
                                      last edited by

                                      @guy038 Haha, well this was really a bit unusual.
                                      Big big thanks for the help, it was exactly what i needed!
                                      Best wishes!

                                      1 Reply Last reply Reply Quote 1
                                      • First post
                                        Last post
                                      The Community of users of the Notepad++ text editor.
                                      Powered by NodeBB | Contributors