Files
Nim/tests/misc/t16541.nim
Bung c25621d153 fix #16541 (#21148)
(cherry picked from commit c5a72ebddd)
2023-04-26 12:48:12 +02:00

13 lines
344 B
Nim

discard """
action: "reject"
"""
import strutils, sugar, nre
proc my_replace*(s: string, r: Regex, by: string | (proc (match: string): string)): string =
nre.replace(s, r, by)
discard my_replace("abcde", re"[bcd]", match => match.to_upper) == "aBCDe"
discard my_replace("abcde", re"[bcd]", (match: string) => match.to_upper) == "aBCDe"