简体   繁体   中英

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. I use a online .NET regex tester to validate that it will work in the workflow.

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

.NET Regex Sample

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

^WHEN:\s(.*?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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