使用正则表达式匹配多行中的两组字符串
Matching two sets of strings from multi lines using Regex
任何人都可以帮助我在正则表达式捕获中创建如下 results/matches 的模式?尝试了下面的模式,只有当下一个字符串在同一行而不是 nextline
时它才有效
Pattern: (?<= <abc xyz=“123>\n<def id=“the_quick_brown_fox)(?s)[A-Z0-9]{9}
<abc xyz=“123>
<def id=“the_quick_brown_foxABC123456” the1andonly
Akfkfkfjfjfjf fkdkfkfkfkf dkdkfkfk
1445gkfkfkfk rkfkfkfkfk tkfkfkfk
<abc xyz=“123>
<def id=“the_quick_brown_foxDEF123456” the1andonly
Dkckfkfkf rifkfkqq fkfkfkqq tkfkfk
Qkekfjj ffkfkf krkfkfk wkkdkfkf rkfkf
<abc xyz=“123>
<def id=“the_quick_brown_foxGHI123456” the1andonly
Matched:
ABC123456
DEF123456
GHI123456
您可以使用
<abc xyz=“123>\R<def id=“the_quick_brown_fox\s*\K[A-Z0-9]{9}
详情:
<abc xyz=“123>
- 文字文本
\R
-换行符
<def id=“the_quick_brown_fox
- 文字
\s*
- 零个或多个空格
\K
- 忘记到目前为止匹配的文本
[A-Z0-9]{9}
- 九个字母数字。
任何人都可以帮助我在正则表达式捕获中创建如下 results/matches 的模式?尝试了下面的模式,只有当下一个字符串在同一行而不是 nextline
时它才有效 Pattern: (?<= <abc xyz=“123>\n<def id=“the_quick_brown_fox)(?s)[A-Z0-9]{9}
<abc xyz=“123>
<def id=“the_quick_brown_foxABC123456” the1andonly
Akfkfkfjfjfjf fkdkfkfkfkf dkdkfkfk
1445gkfkfkfk rkfkfkfkfk tkfkfkfk
<abc xyz=“123>
<def id=“the_quick_brown_foxDEF123456” the1andonly
Dkckfkfkf rifkfkqq fkfkfkqq tkfkfk
Qkekfjj ffkfkf krkfkfk wkkdkfkf rkfkf
<abc xyz=“123>
<def id=“the_quick_brown_foxGHI123456” the1andonly
Matched:
ABC123456
DEF123456
GHI123456
您可以使用
<abc xyz=“123>\R<def id=“the_quick_brown_fox\s*\K[A-Z0-9]{9}
详情:
<abc xyz=“123>
- 文字文本\R
-换行符<def id=“the_quick_brown_fox
- 文字\s*
- 零个或多个空格\K
- 忘记到目前为止匹配的文本[A-Z0-9]{9}
- 九个字母数字。