in reply to Regex puzzle for you
Update: spoiler hidden. (Thanks Zaxo for being clever about it.)
Your problem description could be more specific. If you want to strip leading and trailing underscores, a non-greedy match in the parens would be best. If you know that you're going to strip exactly two underscores (for instance, if you're expecting __DATA__ and the like as input), specifying exactly two underscores around the captures would be a good idea.
In any case, I think the moral of this story is that regexes aren't terribly intuitive. If this regex was designed with something like "Well, I know I'll have a bunch of _s, then some other stuff, then a bunch of _s, and I want to grab the stuff in between", then I sympathize entirely.
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
% man 3 strfry
|
|---|