From be3074aa7b616f4d35b17741b12bed592d97d680 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Thu, 28 Feb 2019 19:51:44 +0100 Subject: [PATCH] Match colors --- samples/test1 | 2 +- src/state.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/test1 b/samples/test1 index 8b60f1e..1b40a2b 100644 --- a/samples/test1 +++ b/samples/test1 @@ -7,7 +7,7 @@ sit amet elit sit amet, https://en.wikipedia.org/wiki/ vehicula porttitor dolor 😋. In 😏, rhoncus some UTF(😁) dignissim iaculis ac. Ip 10.0.3.4 Morbi eu elit sed eros f79010f2 ultricies 67ef359ea8 consequat. Morbi mattis dolor mi, ac faucibus justo maximus eu. Donec vestibulum lorem semper, -ultricies libero 5734d923afb8 efc9061663 ac, imperdiet ex. Morbi +ultricies libero 5734d923afb8 efc9061663 ac, #ff00FF ex. Morbi 123e4567-e89b-12d3-a456-426655440000 tempor mollis condimentum. lorem /var/log/123e4567/999.log lorem /etc/system.conf lorem diff --git a/src/state.rs b/src/state.rs index db1fa4a..3c81a1c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -37,6 +37,7 @@ impl<'a> State<'a> { patterns.push(Regex::new(r"--- a/([^ ]+)").unwrap()); // Diff patterns.push(Regex::new(r"\+\+\+ b/([^ ]+)").unwrap()); // Diff patterns.push(Regex::new(r"[^ ]+/[^ ]+").unwrap()); // Paths + patterns.push(Regex::new(r"#[0-9a-fA-F]{6}").unwrap()); // Hex colors patterns.push(Regex::new(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").unwrap()); // Uid patterns.push(Regex::new(r"[0-9a-f]{7,40}").unwrap()); // Sha id patterns.push(Regex::new(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}").unwrap()); // Ip address @@ -213,6 +214,13 @@ mod tests { assert_eq!(match_lines(output).len(), 3); } + #[test] + fn match_hex_colors () { + let output = "Lorem #fd7b56 lorem #FF00FF\n Lorem #00fF05 lorem #abcd00 lorem #afRR00"; + + assert_eq!(match_lines(output).len(), 4); + } + #[test] fn match_process_port () { let output = "Lorem 5695 52463 lorem\n Lorem 973113 lorem 99999 lorem 8888 lorem\n 23456 lorem 5432 lorem 23444";