in reply to Re: Regex puzzle for you
in thread Regex puzzle for you

I understand your point with:
/\b_+(\w+[^_])_+\b/
But this is not equivalent, as it requires at least 2 characters in the parens, whereas my original
/\b_+(\w+)_+\b/
only requires 1.

Also, your regex will match lots of things in \W, instead of [a-zA-Z0-9]. Using this would be closer to what I meant:
/\b_+(\w*[^_])_+\b/
In fact, reconsidering the original problem, I should have done something more like
/\b_+([a-zA-Z]\w*[a-zA-Z0-9])_+\b/
because I want at least one [a-zA-Z] (although that too fails for "__x__"). Through sheer laziness, I've decided on:
/\b_+(\w+?)_+\b/
even though this lets through pathological cases such as "_____" which I hadn't originally considered.

-QM
--
Quantum Mechanics: The dreams stuff is made of