Re: Regex puzzle for you
by Zaxo (Archbishop) on Aug 03, 2004 at 23:46 UTC
|
| [reply] |
Re: Regex puzzle for you
by FoxtrotUniform (Prior) on Aug 03, 2004 at 23:59 UTC
|
| [reply] [d/l] |
Re: Regex puzzle for you
by injunjoel (Priest) on Aug 04, 2004 at 00:59 UTC
|
| [reply] [d/l] [select] |
|
|
| [reply] [d/l] |
Re: Regex puzzle for you
by ccn (Vicar) on Aug 04, 2004 at 07:43 UTC
|
'__xxx__' =~
m/
\b # word boundary, matches begin of the string
_+ # matches a couple of '_' because greedy
(\w+) # matches the rest(greedy) but must do backtrack for whol
+e regexp match
_+ # after one backtrack matches last '_'
\b
/x;
| [reply] [d/l] [select] |
Re: Regex puzzle for you
by johnnywang (Priest) on Aug 04, 2004 at 02:07 UTC
|
print '__xxx__' =~ /\b_+(\w+?)_+\b/ ? "$1\n" : "no match\n";
| [reply] [d/l] |
Re: Regex puzzle for you
by Gilimanjaro (Hermit) on Aug 04, 2004 at 10:37 UTC
|
Will work if you make it (\w+?) instead...
And I didn't look at any other replies!
What did I win? | [reply] |
|
|
Jack, tell him what he's won!
You've won a 1965 Food Processor by Oster! Unfortunately, the instructions were fed to the machine in 1982 on Christmas Day when it caused the souffle to fall. It has since been run over by a giant Tonka truck, and will be delivered in a yard bag, as soon as we can find the last 3 screws that fell down the gutter drain.
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] |
|
|
Yay!
And There Was Much Rejoicing!
| [reply] |
Re: Regex puzzle for you
by Anonymous Monk on Aug 04, 2004 at 03:27 UTC
|
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)
| [reply] [d/l] |
|
|
| [reply] [d/l] [select] |
Re: Regex puzzle for you
by ambrus (Abbot) on Aug 04, 2004 at 18:10 UTC
|
My guess is this:
Spoiler:
It prints xxx_ because \w matches _.
|
| [reply] [d/l] |
Re: Regex puzzle for you
by Jasper (Chaplain) on Aug 05, 2004 at 16:10 UTC
|
The biggest puzzle is how a perl saint got bitten by this at all. ;) | [reply] |
|
|
I think it's more of a puzzle that you think they don't! :p
A few actually post their D'oh experiences, for the rest of us to learn from [and sometimes laugh at [quietly [ to ourselves ]]].
I propose that anyone who doesn't experience these episodes isn't human, or isn't truthful.
Besides, it doesn't take much to get to saint level anyway. Login every day, vote on stuff, and ask useful questions. You never have to contribute anything original, but it helps. [It seems someone posted once how long it takes to become a saint without posting, but I forget the answer.]
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] |
|
|
Besides, it doesn't take much to get to saint level anyway. Login every day,
vote on stuff, and ask useful questions. You never have to contribute
anything original, but it helps. [It seems someone posted once how long it
takes to become a saint without posting, but I forget the answer.]
We have a a Saint without nodes
(he might have posted some nodes that got deleted later,
I don't know.)
| [reply] |
|
|
It seems someone posted once how long it takes to become a saint without posting, but I forget the answer.
See Sainthood via Seniority Simulation which comes up with 450 to 500 days of daily login and using all your votes.
| [reply] |