diff --git a/regex_macros/tests/tests.rs b/regex_macros/tests/tests.rs index ecd965ff8f..81f3c497c7 100644 --- a/regex_macros/tests/tests.rs +++ b/regex_macros/tests/tests.rs @@ -189,6 +189,8 @@ replace!(rep_all, replace_all, r"\d", "age: 26", "Z", "age: ZZ"); replace!(rep_groups, replace, r"(\S+)\s+(\S+)", "w1 w2", "$2 $1", "w2 w1"); replace!(rep_double_dollar, replace, r"(\S+)\s+(\S+)", "w1 w2", "$2 $$1", "w2 $1"); +replace!(rep_adjacent_index, replace, + r"([^aeiouy])ies$", "skies", "$1y", "sky"); replace!(rep_no_expand, replace, r"(\S+)\s+(\S+)", "w1 w2", NoExpand("$2 $1"), "$2 $1"); replace!(rep_named, replace_all, diff --git a/src/re.rs b/src/re.rs index 845f53a010..c4ecd669ba 100644 --- a/src/re.rs +++ b/src/re.rs @@ -780,7 +780,7 @@ impl<'t> Captures<'t> { pub fn expand(&self, text: &str) -> String { // How evil can you get? // FIXME: Don't use regexes for this. It's completely unnecessary. - let re = Regex::new(r"(^|[^$]|\b)\$(\w+)").unwrap(); + let re = Regex::new(r"(^|[^$]|\b)\$(\d+|\w+)").unwrap(); let text = re.replace_all(text, |refs: &Captures| -> String { let pre = refs.at(1).unwrap_or(""); let name = refs.at(2).unwrap_or("");