diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index 5c6356368..17bd8d524 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -133,6 +133,11 @@ impl Command for SubCommand { example: r#"'abc abc abc' | str replace -a 'b' 'z' -s"#, result: Some(Value::test_string("azc azc azc")), }, + Example { + description: "Use captures to manipulate the input text", + example: r#""abc-def" | str replace "(.+)-(.+)" "${2}_${1}""#, + result: Some(Value::test_string("def_abc")), + }, Example { description: "Find and replace with fancy-regex", example: r#"'a successful b' | str replace '\b([sS])uc(?:cs|s?)e(ed(?:ed|ing|s?)|ss(?:es|ful(?:ly)?|i(?:ons?|ve(?:ly)?)|ors?)?)\b' '${1}ucce$2'"#,