2017-10-20 47 views
-1

我在記事本++中遇到了正則表達式的問題。我需要在製表符分隔的文件中出現第n個選項卡後找到值(其值爲1或0)。標籤之間的文字可能會有所不同,所以基本上沒有任何模式,除了標籤計數。有任何想法嗎?正則表達式在第n次出現tab後找到值

^.*?\t0\t 

這不起作用,因爲可能有其他地方的0在一行。

+1

請提供一些示例文本和預期輸出。 –

+1

嘗試一下:'^(?:[^ \ t] + \ t){5}([01])\ b'用您想要跳過的號碼改變'5'。 – Toto

+1

@Toto說什麼:)只有如果應該允許空字段,請將'+'更改爲'*'。即'^(?:[^ \噸] * \ t)的{5}([01])\ B'。 – ClasG

回答

0
  • 按Ctrl +˚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

相關問題