TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What are your Ruby Regex Idioms?

30 点作者 rahulvohra超过 15 年前

6 条评论

sant0sk1超过 15 年前
I use Rubular all the time for testing my regexes with ease. Give it a shot, its really well done:<p><a href="http://rubular.com/" rel="nofollow">http://rubular.com/</a>
评论 #968219 未加载
nanijoe超过 15 年前
This (ruby) regex thing still gives me a headache , esp when I'm trying to figure out other people's code
评论 #968441 未加载
评论 #968459 未加载
评论 #968242 未加载
sofal超过 15 年前
One of my favorite patterns:<p><pre><code> _, username, domain = */([^@]+)@(.+$)/.match("foo@example.com")</code></pre>
评论 #967930 未加载
评论 #967921 未加载
iamwil超过 15 年前
I didn't see it mentioned, but, btw, this code allows a method to introspect to figure out what the method name that's currently being executed.<p>caller[0][/`([^']*)'/, 1]<p>Note that you only need to do this for Ruby 1.8. In Ruby 1.9, there will be a __method__() and __callee__() method that does the same thing.
zzleeper超过 15 年前
Woah.. I want that for Python..
评论 #968041 未加载
grandalf超过 15 年前
<p><pre><code> (foo){2,5}</code></pre>