<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I've used \b for this. i.e., /\bfoo\b/ - the \b is a zero-width word/nonword boundary, and I use it a lot to anchor at separators. <div><br></div><div>All the best</div><div>Stuart</div><div><br></div><div><br><div><div>On 2013-04-29, at 1:52 PM, Indy Singh wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div style="FONT-FAMILY: 'Calibri'; COLOR: #000000; 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> 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'; COLOR: #000000; 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></body></html>