正则表达式在第n次出现tab后找到值

时间:2017-10-20 11:51:15

标签: regex notepad++ tab-delimited-text

我在记事本++中使用正则表达式时遇到了麻烦。我需要在制表符分隔文件中第n次出现选项卡后找到该值(将为1或0)。选项卡之间的文本可能不同,因此除了选项卡计数外基本上没有模式。有什么想法吗?

^.*?\t0\t

这不起作用,因为可能有其他地方有0行。

1 个答案:

答案 0 :(得分:1)

  • 控制 + ˚F
  • 找到:^(?:[^\t\r\n]+\t){5}([01])(?:\t|$)
  • 检查环绕
  • 检查正则表达式
  • 请勿检查. matches newline
  • 在文件中搜索

<强>解释

^               : 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

您想要的数字在第1组

相关问题