Community
    • Login

    need help with this

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.9k 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.
    • Joe BlowJ
      Joe Blow
      last edited by Joe Blow

      ok take these lines for example

      BodyArmour StabVest
      Training 99.99999
      TazerTrained true
      END

      and

      BodyArmour StabVest
      END

      notice after bodyarmour the first example has training and tazertrained true…

      the formula I have been using for finding is:
      BodyArmour .+ StabVest\K.+(?= )

      my replacement formula is:
      $0\n\t\tTraining\t\t\t 99.99999\r\n\t\tTazerTrained\t\t true

      question…
      how can I change the formula so that only the line entries that don’t already have the training and tazertrained lines get changed…

      because this formula, everytime I use it, it adds that onto all entries

      I just need the extra lines to be added to the entries that need it, not the ones that already have it.

      here is the file for testing:
      http://www.filedropper.com/test_257

      1 Reply Last reply Reply Quote 0
      • cipher-1024C
        cipher-1024
        last edited by

        Hi Joe,
        I think what you’re looking for is a negative lookahead. Something like this:

        (BodyArmour\s+?StabVest(\s+?)?\r\n)(?!(\s*?)Training)

        so you’re looking for a line (possibly with a space at the end) where the next line doesn’t start with some possible white space and “Training”. You can add the additional text like the 99.9999 and the next line if required.

        Your replace line could then look something like this:
        \1\t\tTraining\t\t\t 99.99999\r\n\t\tTazerTrained\t\t true\r\n

        Where the \1 is the first pair of parenthesis in the “find” regex. I’m not able to download your example file from work (blocked by our proxy), but if the “Training” and the “TazerTrained” can be in any order your regex will be more complicated. It could be done, but you may be using the wrong tool at that point.

        A friendly word of advice: when you’re posting a question, put a very general description in the topic, you’ll probably get more traffic and thus quicker help.

        Hope this helps. Good luck!

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