Clojure

Make re-pattern accept multiple arguments to concatenate them.

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None

Description

This would help concatenating multiple regular expressions. The attached patch simply converts all arguments to a string and then pass that string to re-pattern. Currently if you're trying to concatenate literal regular expressions, you're force to use the str function. It's not much extra code, but given the similarity between re-pattern and str, I thought it would be nice to have them behave the same way. e.g.:

(re-pattern (apply str (map (partial format "%s{%s}") [\a \b \c \d \e] (iterate inc 1))))
would become
(apply re-pattern (map (partial format "%s{%s}") [\a \b \c \d \e] (iterate inc 1)))

It only save one call to str, so it might not warrant the extra code in the end.

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/238 Attachments: 0001-Changed-re-pattern-to-accept-multiple-arguments-to-c.patch - https://www.assembla.com/spaces/clojure/documents/barzR2-Jyr3OGheJe5aVNr/download/barzR2-Jyr3OGheJe5aVNr
Hide
Assembla Importer added a comment -

richhickey said: Could you please put an example of what the enhancement would let you do, in the description? Thanks.

Show
Assembla Importer added a comment - richhickey said: Could you please put an example of what the enhancement would let you do, in the description? Thanks.
Hide
Assembla Importer added a comment -

richhickey said: I don't see the need for this

Show
Assembla Importer added a comment - richhickey said: I don't see the need for this

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: