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


In reply to Re: Re: Re: Prog. Perl 3rd Ed. Regex Question by davido
in thread Prog. Perl 3rd Ed. Regex Question by makar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.