neversaint has asked for the wisdom of the Perl Monks concerning the following question:
Dear Masters,
I have the following problem. Given a string:
I have the following problem. Given a string:
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):TXXXABCDGXXXCCCDTGYYYCCCYYYCC
However the following code of mine doesn't seem to do the job? What can I do to achieve that?XXXABCDGXXXCCCDTGYYYCCCYYY XXXABCDGXXXCCCDTGYYY XXXCCCDTGYYYCCCYYY XXXCCCDTGYYY
#!/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.......
neversaint and everlastingly indebted.......
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Delimited Backtracking with Regex
by ikegami (Patriarch) on Apr 21, 2006 at 02:06 UTC | |
by japhy (Canon) on Apr 21, 2006 at 02:14 UTC | |
by ikegami (Patriarch) on Apr 21, 2006 at 02:26 UTC | |
by blokhead (Monsignor) on Apr 21, 2006 at 03:07 UTC | |
by neversaint (Deacon) on Apr 21, 2006 at 02:24 UTC | |
Re: Delimited Backtracking with Regex
by McDarren (Abbot) on Apr 21, 2006 at 01:59 UTC |
Back to
Seekers of Perl Wisdom