+
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ ruplacer '(\w+), (\w+)' '$2 $1'

(note the use of single quotes to avoid any processing by the shell)

`${1}` and `${2}` are also supported as an alternative to `$1` and `$2`, see
[reference
here](https://docs.rs/regex/1.5.5/regex/struct.Regex.html#replacement-string-syntax).
Useful if the replacement string is immediately adjacent to literal text.

If you don't want the pattern to be used as a regex, use the `--no-regex` command line flag.

Expand Down
5 changes: 3 additions & 2 deletions src/replacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,10 @@ mod tests {
fn test_regex_with_substitutions() {
let input = "first, second";
let regex = Regex::new(r"(\w+), (\w+)").unwrap();
let query = Query::regex(regex, r"$2 $1");
// ensure ${1}text syntax works as expected
let query = Query::regex(regex, r"$2 ${1}third");
let replacement = replace(input, &query).unwrap();
assert_eq!(replacement.output(), "second first");
assert_eq!(replacement.output(), "second firstthird");
}

#[test]
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载