Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regex Anchors confusion

by inman (Curate)
on May 18, 2005 at 14:23 UTC ( [id://458225]=note: print w/replies, xml ) Need Help??


in reply to Regex Anchors confusion

The second test is looking for a word boundary, followed by a space, followed by a word boundary, followed by the end of the string.

The pattern doesn't match your data. I can't immediately think of a situation where / \b$/ would ever match.

Replies are listed 'Best First'.
Re^2: Regex Anchors confusion
by japhy (Canon) on May 18, 2005 at 15:14 UTC
    Since \b matches in between a word character and a non-word character, / \b$/ can never match.

    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
      Well, technically, \b matches between a word character, and the failure to match a word character (such as the edge of a string). I know you know that. This is for others that are following along at home. {grin}

      So, there are four pairs: word-word, word-nonword, edge-word, edge-nonword. \b matches the middle two of those, and \B matches the outer two of those.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://458225]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2025-07-10 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.