in reply to regex capture group problem

Hello midiperl,

I also tried using a while loop to read the file in line by line and match each line against the combined regex - but that did not capture both patterns either.

Well, since you specify that The patterns are not on the same line of text, the following approach also works:

use strict; use warnings; use feature 'say'; while (<DATA>) { say $1 if /#augment:(?:A|B)(.*)/; } __DATA__ First line of the file used for filler #augment:A Something One Another line of text for filler #augment:B Something Two Last line of the file used for filler

Output:

13:20 >perl 1350_SoPW.pl Something One Something Two 13:21 >

P.S. Please fix the formatting of your post by changing <\code> to </code>.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,