http://qs321.pair.com?node_id=601772


in reply to Regex solution needed

Since perl doesn't have a "look behind"

Actually, Perl has a lookbehind (see perlre). What Perl doesn't have is variable length lookbehind, so if you do want lookbehinds of different lengths, they need to be multiple lookbehinds. Furthermore, the \s* makes it require one more lookbehind. This ought to do it though:

/(?<!a)(?<!the)(?<!game)(?<!\s)\s*cock/

... though I suspect you really want to ensure word boundaries ... and add some /x whitespace for readability:

/ (?<! \b a ) (?<! \b the ) (?<! \b game ) (?<! \s ) \s* cock \b /x

(But that's just a guess, and in any case beyond your question, so you may want to pretend I did not say that.)

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!