summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2017-01-10 16:43:28 -0500
committerAndrew Gallant <jamslam@gmail.com>2017-01-10 16:43:28 -0500
commit2143bcf9cb259c2230aa79a7cbc23cb1ec1fdae7 (patch)
tree1bd07c466544281ad7381321e3ef3c97a4b0ef6b /doc
parenta6a24bafb383a149ff22504be640569563e63b41 (diff)
Add example to -r/--replace docs.
Fixes #308
Diffstat (limited to 'doc')
-rw-r--r--doc/rg.111
-rw-r--r--doc/rg.1.md6
2 files changed, 17 insertions, 0 deletions
diff --git a/doc/rg.1 b/doc/rg.1
index 5c21b0d9..95539939 100644
--- a/doc/rg.1
+++ b/doc/rg.1
@@ -340,6 +340,17 @@ Neither this flag nor any other flag will modify your files.
.PP
Capture group indices (e.g., $5) and names (e.g., $foo) are supported in
the replacement string.
+.PP
+Note that the replacement by default replaces each match, and NOT the
+entire line.
+To replace the entire line, you should match the entire line.
+For example, to emit only the first phone numbers in each line:
+.IP
+.nf
+\f[C]
+rg\ \[aq]^.*([0\-9]{3}\-[0\-9]{3}\-[0\-9]{4}).*$\[aq]\ \-\-replace\ \[aq]$1\[aq]
+\f[]
+.fi
.RE
.TP
.B \-s, \-\-case\-sensitive
diff --git a/doc/rg.1.md b/doc/rg.1.md
index 3ac61851..7f19cecf 100644
--- a/doc/rg.1.md
+++ b/doc/rg.1.md
@@ -231,6 +231,12 @@ Project home page: https://github.com/BurntSushi/ripgrep
Capture group indices (e.g., $5) and names (e.g., $foo) are supported
in the replacement string.
+ Note that the replacement by default replaces each match, and NOT the
+ entire line. To replace the entire line, you should match the entire line.
+ For example, to emit only the first phone numbers in each line:
+
+ rg '^.*([0-9]{3}-[0-9]{3}-[0-9]{4}).*$' --replace '$1'
+
-s, --case-sensitive
: Search case sensitively. This overrides --ignore-case and --smart-case.