Uploaded image for project: 'Clojure'
  1. CLJ-753

clojure.string/replace-first returns nil with replacement fn when regex doesn't match

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: Backlog
    • Labels:
      None
    • Approval:
      Vetted
    • Patch:
      Code and Test

      Description

      Originally reported by Takahiro Hozumi

      With a function as the "replacement" argument, clojure.string/replace-first returns nil if there is no match, instead of returning the original string unchanged.

      user=> (use 'clojure.string)
      nil
      user=> (replace-first "abcdef" "ghi" "jkl")
      "abcdef"
      user=> (replace-first "abcdef" #"ghi" "jkl")
      "abcdef"
      user=> (replace-first "abcdef" #"ghi" (fn [a] "jkl"))
      nil
      

        Attachments

          Activity

            People

            • Assignee:
              stuart.sierra Stuart Sierra
              Reporter:
              stuart.sierra Stuart Sierra
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: