You can omit the caret in that one too.
Only if I was golfing and not worried about being clear and working in all
circumstances. I never trust the empty match, since it depends on the most
recent successful match. True, here, it defaults to an empty string, but
why count on that when one single character fixes that problem and communicates
the proper intent?
-- Randal L. Schwartz, Perl hacker
| [reply] |
In Perl "// == /$&/".
Is it unintentional or useful feature?
I can't imagine any situation when this feature is helpful.
| [reply] |
Because you were in the midst of a golfing match.
| [reply] |
Because you were in the midst of a golfing match.
No, I wasn't. Read the thread carefully. I responded for my simple mechanism in response to a snippets posting. Part of that posting suggested that some of the original ideas might be good golfing, but that's not where I went with it.
So, if not golfing, then practice safe regex. {grin}
-- Randal L. Schwartz, Perl hacker
| [reply] |