Skip to content

Commit

Permalink
Use verbose mode for the line regex
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Apr 9, 2018
1 parent 1f18a80 commit 1d1d44d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ pub type ParsedLine = Result<Option<(String, String)>>;

pub fn parse_line(line: &str) -> ParsedLine {
lazy_static! {
static ref LINE_REGEX: Regex = Regex::new(concat!(
r"^(\s*(",
r"#.*|", // A comment, or...
r"\s*|", // ...an empty string, or...
r"(export\s+)?", // ...(optionally preceded by "export")...
r"(?P<key>[A-Za-z_][A-Za-z0-9_]*)", // ...a key,...
r"=", // ...then an equal sign,...
r"(?P<value>.+?)?", // ...and then its corresponding value.
r")\s*)[\r\n]*$"
)).unwrap();
static ref LINE_REGEX: Regex = Regex::new(r#"(?x)
^(
\s*
(
\#.*| # A comment, or...
\s*| # ...an empty string, or...
(export\s+)? # ...(optionally preceded by "export")...
(?P<key>[A-Za-z_][A-Za-z0-9_]*) # ...a key,...
= # ...then an equal sign,...
(?P<value>.+?)? # ...and then its corresponding value.
)\s*
)
[\r\n]*
$
"#).unwrap();
}

LINE_REGEX
Expand Down

0 comments on commit 1d1d44d

Please sign in to comment.