Regex to find value after nth occurrence of tab

I'm having trouble with a regex in notepad++. I need to find the value (which will be either 1 or 0) after the nth occurrence of tab in a tab delimited file. Text between tabs may differ, so basically there is no pattern except the tab count. Any ideas?

^.*?\t0\t

This does not work because there may be other places with 0 in line.

1 answer

  • answered 2017-10-20 11:51 Toto

    • Ctrl+F
    • Find what: ^(?:[^\t\r\n]+\t){5}([01])(?:\t|$)
    • check Wrap around
    • check Regular expression
    • DO NOT CHECK . matches newline
    • Search in document

    Explanation:

    ^               : begining of line
      (?:           : start non capture group
        [^\t\r\n]+  : 1 or more character  that is not tab or linebreak
        \t          : a tabulation
      ){5}          : group must appear 5 times (change 5 by any number you want)
      (             : start group 1
        [01]        : 1 digit 0 or 1
      )             : end group 1
      (?:           : non capture group
        \t          : a tabulation
       |            : OR
        $           : end of line
      )             : end group
    

    The digit you want is in group #1