简体   繁体   English

行中的记事本++搜索组合

[英]Notepad++ search combination in lines

I am looking for a specific combination in a txt file that contains multiple lines (Notepad ++). 我正在寻找包含多行(记事本++)的txt文件中的特定组合。 The structure of a line I am looking for is as follows: 我正在寻找的线的结构如下:

xxxxxx  N  N  -1  -1  -1  N (end line)

So I first have an identifier of 6 or more characters, followed by 6 numbers (N) spaced by a tab. 因此,我首先有一个6个或更多字符的标识符,然后是6个数字(N),以制表符分隔。 N can be values 1, 0 or -1. N可以为值1、0或-1。 I am looking for those lines that contain '-1' in position 3, 4 and 5. The other positions can take any of the 3 values. 我正在寻找在位置3、4和5中包含“ -1”的行。其他位置可以采用3个值中的任何一个。 I have searched online and applied searches such as: 我已经在线搜索并应用了搜索,例如:

\t-?\t-?\t-1\t-1\t-1\t-?

\t?.\t?.\t-1\t-1\t-1\t?.

t?.\t?.\t-1\t-1\t-1\t?.\n

\t-1\t-1\t-1\t?.\n

Yet, the last N in the line is not taken into account, so that if its value is 0 for example, that line will not be selected. 但是,该行中的最后N个未考虑在内,因此,例如,如果其值为0,则不会选择该行。

What is the way to write this search? 编写此搜索的方式是什么? I understand Notepad ++ is written in C++. 我知道记事本++是用C ++编写的。

Can you try to follow this pattern?: 您可以尝试遵循这种模式吗:

^([a-zA-Z0-9]{6,})\s*(-1|0|1)\s*(-1|0|1)\s*((-1\s*?){3})\s*(-1|0|1)\s?

https://regex101.com/r/yM5xD3/2 https://regex101.com/r/yM5xD3/2


Explanation: 说明:

^ : Start of the line. ^ :行的开头。

([a-zA-Z0-9]{6,}) : Any character six or more times. ([a-zA-Z0-9]{6,}) :任何字符六次或以上。

\\s* : space/tab/newLine zero o more times. \\s* :空格/制表符/换行零次或多次。

(-1|0|1) : One of those numbers. (-1|0|1) :这些数字之一。

\\s* : ... \\s* :...

(-1|0|1) : One of those numbers. (-1|0|1) :这些数字之一。

((-1\\s*?){3}) : -1 one time followed by space/tab/newLine zero or more times. ((-1\\s*?){3}) :-1一次,然后按space / tab / newLine零次或更多次。 (The '?' means that the regex will try to get the less amount of \\s as possible) (“?”表示正则表达式将尝试获取尽可能少的\\ s)

\\s* : .. \\s* :..

(-1|0|1) : ... (-1|0|1) :...

And the last \\s? 最后一个\\s? : looks for zero or one Space/tab/newLineCharacter :寻找零个或一个空格/制表符/ newLineCharacter

You can try the following regex: 您可以尝试以下正则表达式:

^[a-zA-Z0-9]+\t(-1|0|1)\t(-1|0|1)\t[\-][1]\t[\-][1]\t[\-][1]\t(-1|0|1)$

I tried on the following sample and it worked for me. 我尝试了以下示例,它对我有用。

  xxxxxx    1   1   -1  -1  -1  1
  xxxxxx    0   1   -1  -1  -1  0
  test12    -1  1   -1  1   -1  0
  xxxxxx    1   1   -1  -1  -1  0
  test13    0   1   -1  -1  1   -1

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM