in reply to Re^2: Regex help
in thread Regex help

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

Replies are listed 'Best First'.
Re^4: Regex help
by pKai (Priest) on Jan 15, 2006 at 11:36 UTC
    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?

      (?!\w) and (?=\W) differ at the end of the string.

      (?<=\w) and (?<!\W) differ at the start of the string.

        Oh, I was vaguely aware of it. But I didn't realize that that was the exact point japhy addressed!

        [\b ]*this*, [(?:(?=\w)(?<!\w)|(?=\W)(?<!\W))]*this*, [(?:(?<=\w)(?!\w)|(?<=\W)(?!\W))]this*,* [(?(?=\w)(?<!\w)|(?<!\W)) ]*this*, [(?(?<=\w)(?!\w)|(?!\W)) ]*this*,* [(?:(?=\w)(?<!\w)|(?!\w)(?<=\w))]*this*, [\b ],*that* [(?:(?=\w)(?<!\w)|(?=\W)(?<!\W))]*,*that [(?:(?<=\w)(?!\w)|(?<=\W)(?!\W))],*that* [(?(?=\w)(?<!\w)|(?<!\W)) ]*,*that* [(?(?<=\w)(?!\w)|(?!\W)) ],*that* [(?:(?=\w)(?<!\w)|(?!\w)(?<=\w))],*that*