diff --git a/doc/sed.texi b/doc/sed.texi index a6846b0..6b272ee 100644 --- a/doc/sed.texi +++ b/doc/sed.texi @@ -2265,6 +2265,33 @@ the period character does not match a new-line character in multi-line mode. @end table + +@cindex regex addresses and pattern space +@cindex regex addresses and input lines +Regex addresses operate on the content of the current +pattern space. If the pattern space is changed (for example with @code{s///} +command) the regular expression matching will operate on the changed text. + +In the following example, automatic printing is disabled with +@option{-n}. The @code{s/2/X/} command changes lines containing +@samp{2} to @samp{X}. The command @code{/[0-9]/p} matches +lines with digits and prints them. +Because the second line is changed before the @code{/[0-9]/} regex, +it will not match and will not be printed: + +@codequoteundirected on +@codequotebacktick on +@example +@group +$ seq 3 | sed -n 's/2/X/ ; /[0-9]/p' +1 +3 +@end group +@end example +@codequoteundirected off +@codequotebacktick off + + @node Range Addresses @section Range Addresses diff --git a/doc/sed.x b/doc/sed.x index 401bd88..b2e0beb 100644 --- a/doc/sed.x +++ b/doc/sed.x @@ -257,6 +257,8 @@ Match the last line. .RI / regexp / Match lines matching the regular expression .IR regexp . +Matching is performed on the current pattern space, which +can be modified with commands such as ``s///''. .TP .BI \fR\e\fPc regexp c Match lines matching the regular expression