简体   繁体   English

RegEx匹配两个单词首次出现之间的所有内容,这两个单词都出现多次

[英]RegEx to match everything between first occurrence of two words, both of which appear more than once

I have an email that comes in in which I need to extract the data. 我收到一封电子邮件,其中需要提取数据。 I'm using Nintex Workflows RegEx action with the extract function selected. 我正在使用Nintex Workflows RegEx操作,并选择了提取功能。 I use a online .NET regex tester to validate that it will work in the workflow. 我使用在线.NET正则表达式测试器来验证它是否可以在工作流中正常工作。

My data is like this. 我的数据就是这样。

There is some extra information here that is not needed

WHEN: 12 12:34Z - 12 45:67Z May 16 (I need everything after WHEN:\s until EOL)
WHERE: Around (I do not need this line)

There is some extra information here that is not needed

WHEN: 12 12:34Z - 12 45:67Z May 16 (Duplicate data not needed)
WHERE: Around (I do not need this line)

There is some extra information here that is not needed

I'm using the following code to capture in between two key words. 我正在使用以下代码在两个关键字之间进行捕获。 The problem is that it still matches the duplicate data (?s)(?<=WHEN:\\s).*?(?=WHERE:) 问题在于它仍然匹配重复数据(?s)(?<=WHEN:\\s).*?(?=WHERE:)

.NET Regex Sample .NET正则表达式示例

此正则表达式应在第一个“时间:”之后获取数据:

^WHEN:\s(.*?)

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

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