Match colors

This commit is contained in:
Ferran Basora 2019-02-28 19:51:44 +01:00
parent 1bbc4a9ecd
commit be3074aa7b
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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";