December 2002
Intermediate to advanced
1616 pages
39h 57m
English
The vi and sed editors use regular expressions as search strings within Substitute commands. You can use the ampersand (&) and quoted digits (\n) special characters to represent the matched strings within the corresponding replacement string.
Within a replacement string, an ampersand (&) takes on the value of the string that the search string (regular expression) matched. For example, the following vi Substitute command surrounds a string of one or more digits with NN. The ampersand in the replacement string matches whatever string of digits the regular expression (search string) matched:
:s/[0–9][0–9]*/NN&NN/
Two character class definitions are required because the regular expression [0–9]* matches zero or ...
Read now
Unlock full access