From 730e10bd6f3bc04050a0d3c161c08a6145f61099 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Sun, 21 Jul 2024 23:17:18 -0400 Subject: [PATCH] Support printing `Regular_Expression` in `fmt` --- core/fmt/fmt.odin | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 9aa9c99dc..22ac1cc36 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -9,6 +9,7 @@ import "core:io" import "core:reflect" import "core:strconv" import "core:strings" +import "core:text/regex" import "core:time" import "core:unicode/utf8" @@ -2405,6 +2406,21 @@ fmt_named :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Named) write_padded_number(fi, (ns), 9) io.write_string(fi.writer, " +0000 UTC", &fi.n) return + + case regex.Regular_Expression: + io.write_byte(fi.writer, '/') + for r in a.original_pattern { + if r == '/' { + io.write_string(fi.writer, `\/`) + } else { + io.write_rune(fi.writer, r) + } + } + io.write_byte(fi.writer, '/') + for flag in a.flags { + io.write_byte(fi.writer, regex.Flag_To_Letter[flag]) + } + return } }