in reply to Re: Prog. Perl 3rd Ed. Regex Question
in thread Prog. Perl 3rd Ed. Regex Question

Thank you for the help. I am, however, still not sure why the \b inside the parens is meaningless.
  • Comment on Re: Re: Prog. Perl 3rd Ed. Regex Question

Replies are listed 'Best First'.
Re: Re: Re: Prog. Perl 3rd Ed. Regex Question
by davido (Cardinal) on Feb 13, 2004 at 06:02 UTC
    In the case of this particular regex, the parens are used specifically (and only) for capturing.

    \b is a zero-width assertion. It doesn't match a space, or a character of some sort. It matches when a word character is found next to a nonword character.

    Therefore, there isn't anything in particular to capture when talking about \b. So it's probably not really accurate to say that \b inside parens is meaningless, because it has just as much meaning as it would have outside the parens.

    But that's the crux of it; position inside or outside of the parens is unimportant, in this case, because the function is identical. ...the act of relocating it inside the parens is pointless, because in or out, its function is the same.

    Update: By the way, I ++ed the original question because even though it was pretty basic, it started out with "I'm sitting here reading the camel book." (paraphrasing)

    Kudos to those who do a little homework themselves and come to SoPW for clarification rather than a spoonfeeding. Very good question, in that context.


    Dave