Clojure

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

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Vetted

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

Activity

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: