Get the latest tech news

Fast(er) regular expression engines in Ruby


Performance-oriented comparison of alternative regexp engines that may (or may not) speed up your Ruby code.

Beside the usual HTML parsing, sometimes we're literally forced to fall back to good 'ol regular expressions, e.g. for extracting embedded JS data. I then removed all names from the capture groups, unnecessary escapes and collapsed it to a single line (because not all regex engines support verbose mode). Filtering out regexps one by one, I found that wide scopes like[^a-zA-Z0-9_-] have the same effect as\w in Unicode mode, increasing the scan time significantly, especially if included in non-capturing(?:.)

Get the Android app

Or read this on Hacker News

Read more on:

Photo of ruby

ruby

Photo of Fast(er

Fast(er

Related news:

News photo

Write an Interpreter in Ruby

News photo

Tenjin (YC S14) Is Hiring a Senior Ad Attribution Engineer (Ruby, Go)

News photo

Show HN: I built a Ruby gem that handles memoization with a ttl