[英]How to extract all the strings between 2 patterns using regex Notepad++?
Extract all the string between 2 patterns:提取 2 个模式之间的所有字符串:
Input:输入:
test.output0 testx.output1 output3 testds.output2(\t)
Output: Output:
output0 output1 ouput3 output2
Note: (" ") is the tab character.注意:(" ") 是制表符。
You may try:你可以试试:
\.\w+$
Explanation of the above regex:上述正则表达式的解释:
\.
- Matches .
.
literally..
.
to be included in your pattern;(?<=\.)
or simply remove .
(?<=\.)
或简单地删除.
. \w+
- Matches word character [A-Za-z0-9_]
1 or more time. \w+
- 匹配单词字符[A-Za-z0-9_]
1 次或更多次。$
- Represents end of the line. $
- 代表行尾。 You can find the demo of the regex in here.你可以在这里找到正则表达式的演示。
According to your latest edit;根据您的最新编辑; this might be helpful.
这可能会有所帮助。
.*?\.?(\w+)(?=\t)
Explanation:解释:
.*?
- Match everything other than new line lazily . \.?
- Matches .
.
literally zero or one time.(\w+)
- Represents a capturing group matching the word-characters one or more times. (\w+)
- 表示与单词字符匹配一次或多次的捕获组。(?=\t)
- Represents a positive look-ahead matching tab
. (?=\t)
- 表示正向前瞻匹配tab
。$1
- For the replacement part $1
represents the captured group and a white-space to separate the output as desired by you. $1
- 对于替换部件, $1
代表捕获的组和一个空格,用于根据您的需要分隔 output。 Or if you want to restore tab
then use the replacement $1\t
.tab
,请使用替换$1\t
。 Please find the demo of the above regex in here.请在此处找到上述正则表达式的演示。
Try matching on the following pattern:尝试匹配以下模式:
Find: (?<![^.\s])\w+(?!\S)
Here is an explanation of the above pattern:以下是对上述模式的解释:
(?<![^.\s]) assert that what precedes is either dot, whitespace, or the start of the input
\w+ match a word
(?!\S) assert that what follows is either whitespace of the end of the input
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.