Anyone can help me to create pattern in regex capturing as results/matches below? Tried the below pattern it works only if the next string is on the same line not with the 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
CodePudding user response:
You can use
<abc xyz=“123>\R<def id=“the_quick_brown_fox\s*\K[A-Z0-9]{9}
Details:
<abc xyz=“123>- a literal text\R- line break<def id=“the_quick_brown_fox- literal text\s*- zero or more whitespaces\K- forget the text matched so far[A-Z0-9]{9}- nine alphanumerics.
