Thanks for all the input, guys. I enhanced the initial suggestion to include a few more lookforward possibilities which I think covers enough bases for me to keep it in the dictionary. I omitted the dirty test cases since these are "sacred" boards, but they did get caught correctly :)
my @tests = (
"How bout them cocks?",
"I'm a big cocks fan",
"I love the cocks",
"That cocks game was sweet",
"Anyone know the cocks score from last night?",
"gamecocks rule",
"I love the gamecocks, but...",
"My favorite cocks player is..."
);
foreach my $s (@tests)
{
if ($s =~ /
(?<! \b a )
(?<! \b the )
(?<! \b them )
(?<! \b game )
(?<! \s )
\s* cocks? \b
(?! \s fan )
(?! \s game )
(?! \s score )
(?! \s player )
/x)
{
print "Vulgar: '$s'\n";
}
}
-Darin
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|