From 76f256c9e890f722ee3b21f0fc61a8924c4dc0e0 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Tue, 3 Sep 2024 13:39:04 -0700 Subject: [PATCH] one regex to rule them all --- test-utils/src/dev/test_cmds.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/test-utils/src/dev/test_cmds.rs b/test-utils/src/dev/test_cmds.rs index e8045a9284..792ade0c53 100644 --- a/test-utils/src/dev/test_cmds.rs +++ b/test-utils/src/dev/test_cmds.rs @@ -157,19 +157,14 @@ pub fn redact_variable(input: &str) -> String { // Replace timestamps. // // Format: RFC 3339 (ISO 8601) - // Example: 1970-01-01T00:00:00Z - let s = regex::Regex::new(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z") - .unwrap() - .replace_all(&s, "") - .to_string(); - - // Replace timestamps that have a sub-second portion. - // Example: 1970-01-01T00:00:00.000001Z + // Examples: + // 1970-01-01T00:00:00Z + // 1970-01-01T00:00:00.00001Z // // Note that depending on the amount of trailing zeros, // this value can have different widths. However, "" // has a deterministic width, so that's used instead. - let s = regex::Regex::new(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z") + let s = regex::Regex::new(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z") .unwrap() .replace_all(&s, "") .to_string();