RegEx:获取两个字符串之间的内容,仅适用于包含给定值的记录



在Powershell中,给定以下字符串/记录:

1758,Y9 - Science 2018-19,ACTIVE,Science YR 9 18-19,mydomain.org_classroomd11edec9@group.calendar.google.com

我正在使用正则表达式提取mydomain.org_classroom@group.calendar.google.com:之间的内容

(?<=mydomain.org_classroom)(.*)(?=@group.calendar.google.com)

以上内容将正确提取:11edec9

我需要添加另一个条件:字符串必须包含"ACTIVE",如图所示。

如何添加此条件?

你可以试试这个伴侣

(?<=ACTIVE.*)(?<=mydomain.org_classroom)(.*)(?=@group.calendar.google.com)

正则表达式中缺少什么。

  • (?<=ACTIVE.*)-积极关注。它将匹配一个包含ACTIVE的字符串

演示

最新更新