Unconfigured Ad Widget

Collapse

Need some RegEx Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bluenoise
    Maker of Sound
    CGN Contributor
    • Mar 2009
    • 16061

    Need some RegEx Help

    I'm hoping one of the computer-savvy among you can help me out. I'm trying to do a multi-file search (using Notepad++) to find all the times a pattern does not match my desired pattern.

    Here is the string I want it to be in every instance:
    Code:
    <filter><index>3</index><type>None</type>
    I only want to find/flag times when <type> is NOT equal to "None."

    In other words I'm searching hundreds of files, each containing dozens of this string and I need them to always be None. Rather than just bulk change them, I need to inspect why they're not None.

    I know the XML is not balanced, but that's because I really don't care about the text that follows what I've pasted above.

    Thanks!
    bluenoiseise.
    lllllllllllllllllllllll...
    "Socialism, in general, has a record of failure so blatant that only an intellectual could ignore or evade it." -Thomas Sowell
  • #2
    unusedusername
    Veteran Member
    • Sep 2008
    • 4124

    I'm not familiar with Notepad++, what regex language does it use?

    The key will be the "match anything except "None"" part of the expression, since you need a minimal length match followed by "</type>"

    It's usually easier to find all the other values other then "None" and match them inside an OR instead of trying to match anything except "None".

    Comment

    • #3
      gotMoxie
      Junior Member
      • Jul 2013
      • 30

      This answer on stackoverflow may help. It's going to be pretty dependent on the regex engine your application is using as to the exact formatting but you really are looking for a negative look ahead

      I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a re...


      Hope that helps.

      Comment

      • #4
        SkyHawk
        I need a LIFE!!
        • Sep 2012
        • 23518

        Another thing you might do is just bulk replace that entire string with a null value or a carriage return. Then every other instance of <type> that remains will be something to inspect. Then you don't even need regex and don't need to perform some negative search.

        You could make a copy of your file set into a temp folder before you start, if you did not want to modify the originals.
        Last edited by SkyHawk; 08-31-2016, 1:47 PM.
        Click here for my iTrader Feedback thread: https://www.calguns.net/forum/market...r-feedback-100

        Comment

        • #5
          bluenoise
          Maker of Sound
          CGN Contributor
          • Mar 2009
          • 16061

          Originally posted by gotMoxie
          This answer on stackoverflow may help. It's going to be pretty dependent on the regex engine your application is using as to the exact formatting but you really are looking for a negative look ahead

          I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a re...


          Hope that helps.
          Thank you for that link. That's very close, but I'm having trouble combining the !None with the rest of the string needing to be found.

          Originally posted by SkyHawk
          Another thing you might do is just bulk replace that entire string with a null value or a carriage return. Then every other instance of <type> that remains will be something to inspect. Then you don't even need regex and don't need to perform some negative search.

          You could make a copy of your file set into a temp folder before you start, if you did not want to modify the originals.
          I think this will be the simplest way to go. Thanks!
          bluenoiseise.
          lllllllllllllllllllllll...
          "Socialism, in general, has a record of failure so blatant that only an intellectual could ignore or evade it." -Thomas Sowell

          Comment

          Working...
          UA-8071174-1