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!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regex solution needed
by chargrill (Parson) on Feb 23, 2007 at 17:19 UTC | |
by spivey3587 (Acolyte) on Feb 23, 2007 at 19:47 UTC | |
by ikegami (Patriarch) on Feb 23, 2007 at 20:13 UTC | |
Re^2: Regex solution needed
by spivey3587 (Acolyte) on Feb 23, 2007 at 17:16 UTC | |
Re^2: Regex solution needed
by ikegami (Patriarch) on Feb 23, 2007 at 19:01 UTC | |
by spivey3587 (Acolyte) on Feb 23, 2007 at 19:58 UTC |