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

Federico Brubacher made changes -
Field Original Value New Value
Attachment 0001-clojure.string-replace-first-now-returns-the-origina.patch [ 10157 ]
Chris Perkins made changes -
Chris Perkins made changes -
Stuart Sierra made changes -
Patch Code and Test [ 10002 ]
Approval Vetted [ 10003 ]
Affects Version/s Backlog [ 10035 ]
Fix Version/s Backlog [ 10035 ]
Fix Version/s Approved Backlog [ 10034 ]
Fogus made changes -
Assignee Stuart Sierra [ stuart.sierra ] Fogus [ fogus ]
Fogus made changes -
Assignee Fogus [ fogus ] Stuart Sierra [ stuart.sierra ]
Stuart Sierra made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Stuart Halloway made changes -
Status Resolved [ 5 ] Closed [ 6 ]
Alex Miller made changes -
Fix Version/s Approved Backlog [ 10034 ]
Fix Version/s Backlog [ 10035 ]

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: