Hi , I need some help me to extract a pattern. The delimiters is a pair of "abcd" and "efgh". Can some one help me with an efficient use of Greedy and non greedy matches, look ahead and lookbehind features.
I want the smallest match involving the two delimiters. I want all the matches. i.e. fisrt match , last match and all ther other matches in between. Here is what I tried to extract the first match and the results(a bad one) I got. $abc = <<END; aaaaaaaaaa abcd aaaaa abcd bbbbb AAAAAAAAAAAAAAA BBBBBBBBBBBBBBB efgh ccccc CCCCCCCCCCCCCCC efgh ddddd DDDDDDDDDDDDDDD EEEEEEEEEEEEEEE FFFFFFFFFFFFFFF abcd eeeee abcd fffff GGGGGGGGGGGGGGG HHHHHHHHHHHHHHH IIIIIIIIIIIIIII efgh ggggg efgh hhhhh JJJJJJJJJJJJJJJ KKKKKKKKKKKKKKK END $match = 'abcd(?:(?!abcd).)*efgh.*?\n'; ($found) = ($abc =~ /($match)(?!$match)/sxi); print "*************\nFOUND FIRST MATCH\n$found\n"; The OUTPUT IS : ************* FOUND FIRST MATCH abcd bbbbb AAAAAAAAAAAAAAA BBBBBBBBBBBBBBB efgh ccccc CCCCCCCCCCCCCCC efgh ddddd WHEREAS I wanted it to be ************* FOUND FIRST MATCH abcd bbbbb AAAAAAAAAAAAAAA BBBBBBBBBBBBBBB efgh ccccc Any suggestion is welcome. Thanks in advance. Rajeev -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]