<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 12, 2009, at 11:17 AM, Mike Stok wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I've deleted the rest of the thread, but what about<br><div><br></div><div>$string =~ /^(?:(?!good).)*$/</div><div><br></div><div>to check that $string doesn't contain good?</div><div><br></div><div><div> DB<1> x 'bad' =~ /^(?:(?!good).)*$/</div><div>0 1</div><div> DB<2> x 'good enough' =~ /^(?:(?!good).)*$/</div><div> empty array</div><div><br></div></div><div>Mike</div></div></blockquote><div><br></div>Note that I posted this after discovering it at <a href="http://www.kimgentes.com/worshiptech-web-tools-page/2008/12/20/regular-expressions-except-a-given-string-negative-patterns.html">http://www.kimgentes.com/worshiptech-web-tools-page/2008/12/20/regular-expressions-except-a-given-string-negative-patterns.html</a> which ends with:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="font-family: Georgia; line-height: 19px; ">*YOU ARE FREE to use this algorithm in any application (commercial or personal or whatever). It comes with no warrantees. If you DO end up using this REGEX pattern, please do so with the following considerations:</span></blockquote><div><span class="Apple-style-span" style="font-family: Georgia; font-size: 12px; line-height: 19px; "><ul style="list-style-type: square; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 2em; "><ul style="list-style-type: square; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 2em; "><li>make this notation in your source code: <em>©2008 Kim Anthony Gentes - FREE TO USE ANYWHERE.</em></li><li>Please post a response on this blog entry below (you do that by clicking on the "Comments" link at the bottom of this entry), saying you found this and are using it. I'd just like to know if its helping people and how people are using it.</li></ul></ul></span></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="font-family: Georgia; line-height: 19px; ">When using the regex, some important things to know:</span><br><span class="Apple-style-span" style="font-family: Georgia; line-height: 19px; ">Options (turned on in your language/utility): ^ and $ match at line breaks</span></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Georgia"><span class="Apple-style-span" style="line-height: 19px;"><br></span></font></blockquote><div>so I don't claim to have the brains to invent it or want to claim credit for it (merely the use of the appropriate Google search terms...)</div><div><br></div><div>It is a fun exercise to work through it to see how it works...</div><div><br></div><div>Mike</div><div><br></div><div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 12, 2009, at 10:44 AM, Fulko Hew wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><div class="gmail_quote">On Thu, Mar 12, 2009 at 10:30 AM, Adam Prime <span dir="ltr"><<a href="mailto:adam.prime@utoronto.ca">adam.prime@utoronto.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <br> Fulko Hew wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Alex asked:<br> <br> > Couldn't you just use the ~! on the regex instead of ~=?<br> </blockquote></blockquote><div><br>... snip ...<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> </blockquote> <br> it's !~, not ~!<br> <br> ie:<br> <br> aprime@primepc:~$ cat haha.pl<br> <br> my $text = 'haha';<br> <br> if ($text !~ /hat/) {<br> print qq[yay\n];<br> }<br> else {<br> print qq[yay\n];<br> }<br> aprime@primepc:~$ perl haha.pl<br> yay<br> <br> also, given your example there, why wouldn't you just<br> <br> return true unless $_ eq 'good';<br></blockquote></div><br><br>Because I'm not allowed to rewrite the code, but simply insert a<br>different regex pattern in between the slashes.<br> _______________________________________________<br>toronto-pm mailing list<br><a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/toronto-pm">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="color: rgb(0, 0, 0); font-size: 12px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><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></div><br class="Apple-interchange-newline"></span> </div><br></div>_______________________________________________<br>toronto-pm mailing list<br><a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/toronto-pm">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><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></div><br class="Apple-interchange-newline"></span> </div><br></body></html>