Uploaded image for project: 'ClojureScript'
  1. CLJS-794

RegExp flags are being dropped by `string/replace`

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects versions: 1.7.145
    • Fix versions: 1.9.655
    • Labels:
      None

      Description

      `clojure.string/replace` accepts either a string or pattern argument to match against.

      For pattern arguments, the current implementation discards the original RegExp and creates a new one:
      `(.replace s (js/RegExp. (.-source match) "g") replacement)`

      This is killing any flags on the original pattern (case insensitivity, for example). As a result, things like `(str/replace "Foo" #"(?i)foo" "bar")` currently fail. The result is "Foo", it should be "bar".

      Can I submit a patch that'll check for and preserve other (i/m/y) flags?

      Thanks

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ptaoussanis Peter Taoussanis
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: