TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ruby takes 2min to match a regex

10 pointsby salimaneover 11 years ago

3 comments

kzrdudeover 11 years ago
Let&#x27;s guess that <i>Regular Expression Matching Can Be Simple And Fast</i> is relevant <a href="http://swtch.com/~rsc/regexp/regexp1.html" rel="nofollow">http:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp1.html</a>
srdover 11 years ago
The issue with the regex seems to be the nested * matcher in the last part, paired with the grouping: ([\&#x2F;\w \.-]* )* (whitespace added to re to circumvent italisizing by HN).<p>IIRC this was a pathological case with perl5.0 regexes as well.<p>Removing one of the redundant * or marking the grouping to be non-capturing with ?: seems to fix the problem.<p>Looks like the regex optimizer could use some love.
dhfjgkrgjgover 11 years ago
if you are using Ruby for any performance sensitive task, you are doing it wrong. Really. Even the die hard fans acknowledge they use it for the meta-magic-shiny-shiny rather than something that complete a given task in a reasonable timeframe.<p>Ruby is slow. Dynamic languages often are.
评论 #7226516 未加载
评论 #7226610 未加载
评论 #7226214 未加载