I can confirm the buggy behavior on emacs 24.5.1 and 25.1.50.1 for Kevin's example as well as:
(replace-regexp-in-string "^.\\| ." #'upcase "foo bar")
> "Foo bar" (should be "Foo Bar")
Some close variants which behave correctly:
(replace-regexp-in-string "^F\\| ." #'upcase "foo bar")
> "Foo Bar"
(replace-regexp-in-string "^.K\\| ." #'upcase "ok corral")
> "OK Corral"
(replace-regexp-in-string "^..\\| ." #'upcase "ok corral")
> "OK Corral"
Here is a regression test for when someone has a chance to tackle this:
---
test/lisp/subr-tests.el | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index ce21290..969d5c2 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -224,5 +224,8 @@
(error-message-string (should-error (version-to-list "beta22_8alpha3")))
"Invalid version syntax: `beta22_8alpha3' (must start with a number)"))))
+(ert-deftest replace-regexp-in-string-test ()
+ (should (equal (replace-regexp-in-string "^.\\| ." #'upcase "foo bar") "Foo Bar")))
+
(provide 'subr-tests)
;;; subr-tests.el ends here
--
Regards,
Erik Anderson.