[tpm] String matching at start or middle or end of list
antoniosun at lavabit.com
Mon Apr 29 08:36:56 PDT 2013
On Mon, Apr 29, 2013 at 11:18 AM, J. Bobby Lopez <jbl at jbldata.com> wrote:
> Would this work for your purposes?:
> my $s = 'foo,bar,boo,baz';
> my ($match) = $s =~ /[,]*foo[,]*/;
That'd cast the net too wide for thing like: ' foobar,'
I am looking to match the following:
> The start of a string or a separator followed by
> A specified string followed by
> A separator or the end of the string
> I want to extract the matched string into a variable.
How about doing it separately:
$s =~ /^(foo),|,(foo),|,(foo)$/;
my ($match) = $1;
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm