t16541.nim 344 B

12345678910111213
  1. discard """
  2. action: "reject"
  3. """
  4. import strutils, sugar, nre
  5. proc my_replace*(s: string, r: Regex, by: string | (proc (match: string): string)): string =
  6. nre.replace(s, r, by)
  7. discard my_replace("abcde", re"[bcd]", match => match.to_upper) == "aBCDe"
  8. discard my_replace("abcde", re"[bcd]", (match: string) => match.to_upper) == "aBCDe"