tunafish has asked for the wisdom of the Perl Monks concerning the following question:
Wondering if there is a way to capture only the part of a string matched by regex? If I have the following string:
$string_to_search="This part of the string is what I'm looking for and + I want to capture it. I want to capture all instances of this paart +of the string. Paaaaart of the string!";
How can I capture all strings within that string that match the pattern /pa+rt/i? So what I want for my return is:
@results = ('part','paart','Paaaaart');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capturing string matched by regex
by dave_the_m (Monsignor) on Feb 17, 2012 at 03:38 UTC | |
by tunafish (Beadle) on Feb 17, 2012 at 05:23 UTC | |
|
Re: Capturing string matched by regex
by AnomalousMonk (Archbishop) on Feb 17, 2012 at 04:20 UTC | |
by johngg (Canon) on Feb 17, 2012 at 16:13 UTC | |
by AnomalousMonk (Archbishop) on Feb 17, 2012 at 20:09 UTC | |
by johngg (Canon) on Feb 18, 2012 at 00:08 UTC | |
by AnomalousMonk (Archbishop) on Feb 18, 2012 at 02:41 UTC | |
by tchrist (Pilgrim) on Feb 18, 2012 at 04:43 UTC |