Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^5: regex search for words with one digit

by Bruder Savigny (Initiate)
on Sep 24, 2020 at 00:56 UTC ( #11122143=note: print w/replies, xml ) Need Help??

in reply to Re^4: regex search for words with one digit
in thread regex search for words with one digit

Very instructive! I hadn't looked closely at your code, embarrassingly, and this actually happens to be the first example I can remember where a \b is actually required. And I really can't think up an alternative without it. (It's not that I somehow don't like it, just that I've never had to use it.)

On reflection, I would perhaps have used split and then something with grep {/^...$/} -- much clumsier and also amounting to the same thing in disguise, namely string anchors. I never realised that \b are a kind of ^ and $, but within the text.

(The point I was trying to make -- only half convincingly -- was that I think it's a good habit not to throw in things "for good measure" and move on as soon as it works, because that approach doesn't teach you a lot, and you sometimes walk away with a wrong or (worse!) fuzzy impression of what actually did the trick. Or both. I have experienced this a thousand times.)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2021-03-04 03:11 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (98 votes). Check out past polls.