need help with this
-
ok take these lines for example
BodyArmour StabVest
Training 99.99999
TazerTrained true
ENDand
BodyArmour StabVest
ENDnotice 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 truequestion…
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 -
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\nWhere 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!