]>
git.proxmox.com Git - rustc.git/blob - src/vendor/regex-0.1.80/tests/replace.rs
2 ($name
:ident
, $which
:ident
, $re
:expr
,
3 $search
:expr
, $replace
:expr
, $result
:expr
) => (
7 assert_eq
!(re
.$
which(text
!($search
), $replace
), text
!($result
));
12 replace
!(first
, replace
, r
"\d", "age: 26", t
!("Z"), "age: Z6");
13 replace
!(plus
, replace
, r
"\d+", "age: 26", t
!("Z"), "age: Z");
14 replace
!(all
, replace_all
, r
"\d", "age: 26", t
!("Z"), "age: ZZ");
15 replace
!(groups
, replace
, r
"(\S+)\s+(\S+)", "w1 w2", t
!("$2 $1"), "w2 w1");
16 replace
!(double_dollar
, replace
,
17 r
"(\S+)\s+(\S+)", "w1 w2", t
!("$2 $$1"), "w2 $1");
18 // replace!(adjacent_index, replace,
19 // r"([^aeiouy])ies$", "skies", t!("$1y"), "sky");
20 replace
!(named
, replace_all
,
21 r
"(?P<first>\S+)\s+(?P<last>\S+)(?P<space>\s*)",
22 "w1 w2 w3 w4", t
!("$last $first$space"), "w2 w1 w4 w3");
23 replace
!(trim
, replace_all
, "^[ \t]+|[ \t]+$", " \t trim me\t \t",
25 replace
!(number_hypen
, replace
, r
"(.)(.)", "ab", t
!("$1-$2"), "a-b");
26 // replace!(number_underscore, replace, r"(.)(.)", "ab", t!("$1_$2"), "a_b");
27 replace
!(simple_expand
, replace_all
, r
"(\w) (\w)", "a b", t
!("$2 $1"), "b a");
28 replace
!(literal_dollar1
, replace_all
,
29 r
"(\w+) (\w+)", "a b", t
!("$$1"), "$1");
30 replace
!(literal_dollar2
, replace_all
,
31 r
"(\w+) (\w+)", "a b", t
!("$2 $$c $1"), "b $c a");
32 replace
!(no_expand1
, replace
,
33 r
"(\S+)\s+(\S+)", "w1 w2", no_expand
!("$2 $1"), "$2 $1");
34 replace
!(no_expand2
, replace
,
35 r
"(\S+)\s+(\S+)", "w1 w2", no_expand
!("$$1"), "$$1");