[ale] NewbieQ Perl filtering question

Tim Meanor timothy at meanor.net
Thu Jun 29 17:38:54 EDT 2006


This is kinda ugly, but it should work:
$string1 = string1;
$string2 = string2;
$input = "blah..blah..string1good contentstring2..garbage..garbage";

$tempstring = (split $string1, $input)[1];
$good_content = (split $string2, $tempstring)[0];

or, more compactly:

$good_content = ( split "string2", ( split "string1", input )[1] )[0];


-Tim

On Jun 29, 2006, at 4:57 PM, Mills, John M. wrote:

> ALErs -
>
> I need to return only the part of a text line that falls between two
> expected character strings, as it:
>
> Input: blah..blah..string1<good content>string2..garbage..garbage
> Output: <good_content>
>
> TIA for a bit of guidance.
>
>  - Mills
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale




More information about the Ale mailing list