On Friday, April 12, 2002, at 12:58 PM, David Gray wrote:
>> for e.g : >> >> (not showing the new lines..) >> >> >> ....word1.....word1.....word1....word2....word1...word2....wor >> d2....word2.... >> ..... > > You're gonna want to check out (in the perldoc perlre manpage) (??{ code > }), which is an example of a recursive regular expression. They have an > example that matches nested parenthesis correctly. > > Cool stuff :) > > -dave > but he doesn't want to do nested. as he described he wants text from word1 to word2 where there is no word1 or word2 in between. then he wants to go on to the next pair. something like this: $gotword1 = 0; while(<>) { if ($gotword1) # gather text while($gotword1 or /$word1/) { $gotword1=1; if (/$word2/ before a $word1) { #gather last bunch of text and push it to array or whatever $gotword1=0; } else #gather text } } problem with this code is continuing the search from where the last search ended, knowing if you got $word2 before an instance of $word1, and gathering the text between. but it's a start? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]