Replace with non-matching group

The doc of replace has this example:

julia> replace("The quick foxes run quickly.", r"fox(es)?" => s"bus\1")
"The quick buses run quickly."

this works fine however

julia> replace("The quick fox run quickly.", r"fox(es)?" => s"bus\1")
ERROR: PCRE error: requested value is not set

I imagine that’s not desirable? I have two questions:

  1. am I missing something and is this working the way it should?
  2. is there a workaround I can use for Julia 1+ ? so something which would do
julia> alt_replace("The quick fox run quickly.", r"fox(es)?" => s"bus\1")
"The quick bus run quickly."

Thanks

(Edit: this is on 1.2)

Edit: issue opened with full description including corresponding (working) python code: Replace with optional matching group fails when there is no match · Issue #31456 · JuliaLang/julia · GitHub