Regular expressions can also be used for making replacements. The search
part is the pattern as described above, and the replacement string can
be specified in the same way as this is done for the regular search and
replace command p. . All options
that can be used there apply also for the search and replace with
regular expressions. In addition the replacement string may now also
contain linefeeds (indicated by \n
or <escape><return>).
There is one restriction with respect to the options available for the regular search and replace. Only the forward search modes are available for the regular expressions. There exist no good definitions of a backward mode. One could either try to work back trough the file, matching from the back, or stepping back through the file, matching the pattern from the left to the right. The first method is rather against intuition, while the second method may not yield the `longest' match. Neither is satisfactory.