<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 2013-04-29, at 1:52 PM, "Indy Singh" <<a href="mailto:indy@indigostar.com">indy@indigostar.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div style="font-family: Calibri; font-size: 12pt; ">
<div>Hi All,</div>
<div> </div>
<div>Following Alans suggestion, I am going to repost the question with some 
test cases.</div>
<div> </div>
<div>I am looking for a way to match a string that appears in a comma separated 
list. The string may may appear at the start or middle, end or nowhere on 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>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?</div>
<div> </div>
<div>Test code below. Anywhere where ‘foo’ appears should match but ‘food’ 
should not match</div>
<div> </div>
<div>foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') 
{<br>    print "s=$s ";</div>
<div> </div>
<div>    my ($match) = $s =~ /some reg expression or perl code 
here to match foo/;</div></div></div></div></blockquote><div><br></div>any { $_ eq 'foo' } split(/,/, $s)</div><div><br></div><div>if you're allowed to use List::MoreUtils 'any'</div><div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div style="font-family: Calibri; font-size: 12pt; ">
<div> </div>
<div>    if ($match) 
{<br>        print 
"match=$match\n";<br>    } else 
{<br>        print "no 
match\n";<br>    }<br>}</div>
<div> </div>
<div> </div>
<div style="font-family: Calibri; font-size: 12pt; ">Indy 
Singh<br>IndigoSTAR Software -- 
<a href="http://www.indigostar.com">www.indigostar.com</a></div></div></div></div>
_______________________________________________<br>toronto-pm mailing list<br><a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>http://mail.pm.org/mailman/listinfo/toronto-pm<br></blockquote></div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; font-size: 12px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-- </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Mike Stok <<a href="mailto:mike@stok.ca">mike@stok.ca</a>></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://www.stok.ca/~mike/">http://www.stok.ca/~mike/</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The "`Stok' disclaimers" apply.</div><div><br class="khtml-block-placeholder"></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span>
</div>
<br></body></html>