Hacker News new | ask | show | jobs
by inopinatus 530 days ago
shame about that example, since

    ary.grep /(j|sh)orts/
already exists, and therefore sells the standard library short. try this:

    terms = %w(foo? bar q**x)
    Regexp.new "\\b(#{terms.map { Regexp.escape it }.join ?|})\\b"

    #=> /\b(foo\?|bar|q\*\*x)\b/
and observe that it's at the margins of instant comprehension where syntax shorthands like "it" add value.