-2

I have a log for an app that executes every minute or so and at the end it reports number of records it failed with like this: TaskBlahBlah: [0] records failed

Up until now I would simply search through the whole document for ] records failed string and would visually identify the lines with greater then zero records. Is there a way to use regex and search for any non zero value specifically so I don't have to visually go through the list and potentially miss something?

I tried applying some regex to Notepad++ but it seems that either I did it wrong or Noteppad++ has a 'different' regex or something.

thank you

EDIT: just to list some of the things I tried:

[1-9][0-9]|[1-9] 

\[[1-9][0-9]\] records failed|\[[1-9]\] records failed

For some reason it picks up things like [1] records failed but not [10] records failed

George
  • 2,165
  • 2
  • 22
  • 34
  • 1
    `/\[[1-9]\d*\] records failed/`? – Biffen Feb 08 '16 at 15:47
  • [`(?:records failed)$`](https://regex101.com/r/cR9nU4/2) - bind the search string to the end of the line and use multiline mode. – Jan Feb 08 '16 at 15:50
  • @George: What have you tried? – Wiktor Stribiżew Feb 08 '16 at 16:05
  • @Biffen - it worked perfectly, thank you. – George Feb 08 '16 at 16:05
  • @Jan - Biffen's regex worked, but out of curiosity I wanted to try your approach. However, I don't know how to do what you were asking – George Feb 08 '16 at 16:05
  • @George: I did not ask anything, did I? The idea was to look for `records failed` literally at *the end of every line* (this can be achieved via the dollar sign but only in multi-line mode). – Jan Feb 08 '16 at 16:09
  • @Jan: how does that differ from the search I already did and wanted to improve upon? – George Feb 08 '16 at 16:19
  • @Wiktor: I tried several regex formulas, which did not work. `[1-9][0-9]|[1-9]` being one of them – George Feb 08 '16 at 16:21
  • Whoa, whats up with downvotes? – George Feb 08 '16 at 16:25
  • @Biffen: If you create an answer with your comment, I will accept it. – George Feb 08 '16 at 16:30
  • 1
    @George: See [How to ask](http://stackoverflow.com/help/how-to-ask) and [Should “Give me a regex that does X” questions be closed?](http://meta.stackoverflow.com/questions/285733/should-give-me-a-regex-that-does-x-questions-be-closed/285739#285739) – Wiktor Stribiżew Feb 08 '16 at 16:35
  • Possible duplicate of [What is the regex for "Any positive integer, excluding 0"](http://stackoverflow.com/questions/7036324/what-is-the-regex-for-any-positive-integer-excluding-0) – Biffen Feb 08 '16 at 16:42
  • @Biffen: Thanks, somehow that post totally avoided my searches, and I did search, I'm not a lazy prograbum :) . Thank you again – George Feb 08 '16 at 16:53

1 Answers1

0

I guess this should get what you want:

/\[[1-9]\d*\] records failed/
Svperstar
  • 487
  • 2
  • 10