in reply to Regex help

You don't want to use "word boundary", but rather "boundary". There is no shortcut for boundary, so you'll have to use:
/(?:(?=\w)(?<!\w)|(?=\W)(?<!\W))($thing)(?:(?<=\w)(?!\w)|(?<=\W)(?!\W) +)/
You could also use the (?(...)TRUE|FALSE) assertion to clean that up a bit:
/(?(?=\w)(?<!\w)|(?<!\W))($thing)(?(?<=\w)(?!\w)|(?!\W))/

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: Regex help
by pKai (Priest) on Jan 14, 2006 at 18:29 UTC

    I'm confused. Aren't your left and right side zero length assertions:

    (?(?=\w)(?<!\w)|(?<!\W))

    and

    (?(?<=\w)(?!\w)|(?!\W))

    just synonymous with \b?

      No, \b says there's a word character on exactly one side, like: (?:(?=\w)(?<!\w)|(?!\w)(?<=\w)).
        Hm, I'd think that

        (?!\w) and (?=\W)

        and also

        (?<=\w) and (?<!\W)

        are equivalent!?

        This would unify your "descripted" \b and japhy's "left side boundary".

        Also, if it ... flies like a duck, quacks like a duck. .. It probably is a duck?!:

        Do I have the wrong test cases?