in reply to Regex puzzle for you

I did this:

print '__xxx__' =~ /\b_+(\w+[^_])_+\b/ ? "$1\n" : "no match\n";

Honestly didn't seem that hard (assuming your goal was to strip the underscores)

Replies are listed 'Best First'.
Re^2: Regex puzzle for you
by QM (Parson) on Aug 04, 2004 at 14:09 UTC
    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.

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