Commit 02043558 authored by Scott Abbey's avatar Scott Abbey

Refactor repeated regexes

parent e3e1e015
......@@ -9,10 +9,13 @@ use std::error::Error;
lazy_static! {
static ref REGEX: Regex = {
let major = r"0|(:?[1-9][0-9]*)";
let minor = r"0|(:?[1-9][0-9]*)";
let patch = r"0|(:?[1-9][0-9]*)";
// a numeric identifier is either zero or multiple numbers without a leading zero
let numeric_identifier = r"0|(:?[1-9][0-9]*)";
let major = numeric_identifier;
let minor = numeric_identifier;
let patch = numeric_identifier;
let regex = format!(r"^(?P<major>{})\.(?P<minor>{})\.(?P<patch>{})$", major, minor, patch);
let regex = Regex::new(&regex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment