Hi,<br>Maybe 'if ('foo,bar,boo,baz' =~ /,?foo,?/) { ... } ' is what you're looking for.<br><br>Cheers,<br>Matt<br><br><div class="gmail_quote">On Mon, Apr 29, 2013 at 11:09 AM, Indy Singh <span dir="ltr"><<a href="mailto:indy@indigostar.com" target="_blank">indy@indigostar.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
What is a good way to match a string that may appear at the start or middle or end of a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it.<br>
<br>
<br>
Example:<br>
my $s = 'foo,bar,boo,baz';<br>
my ($match) = $s =~ /(foo)/;<br>
<br>
I am looking to match the following:<br>
The start of a string or a separator followed by<br>
A specified string followed by<br>
A separator or the end of the string<br>
<br>
What are the extra things I need to surround the match expression?<br>
<br>
One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string?<br>
<br>
Indy Singh<br>
IndigoSTAR Software -- <a href="http://www.indigostar.com" target="_blank">www.indigostar.com</a><br>
<br>
______________________________<u></u>_________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/toronto-pm</a><br>
</blockquote></div><br>