http://www.perlmonks.org?node_id=544751

neversaint has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,

I have the following problem. Given a string:
TXXXABCDGXXXCCCDTGYYYCCCYYYCC
I would like to extract all its substring that begins with "XXX" and end with "YYY". Such that it yields the following result (below is done manually):
XXXABCDGXXXCCCDTGYYYCCCYYY XXXABCDGXXXCCCDTGYYY XXXCCCDTGYYYCCCYYY XXXCCCDTGYYY
However the following code of mine doesn't seem to do the job? What can I do to achieve that?
#!/usr/bin/perl -w use strict; use Data::Dumper; use Carp; my $str = "TXXXABCDGXXXCCCDTGYYYCCCYYYCC"; $str =~ m/(XXX.*?YYY)/g; print "$1\n";


---
neversaint and everlastingly indebted.......