Staring in release 1.2.0, the .regex function has a new option, -1. This option tells .regex to read all of its input into a single string and perform the operation on that.

This option is mainlyonly useful when a string substitution is meant to span multiple lines. For example, if you have text in the input stream that looks like this:

file tom.txt:

tom x
is a jerk

And you would like to replace "x<newline>is" with "would be". You can invoke .regex like this:

.regex -1 -p 'x\r\nis'     -r 'would be'    <tom.txt

The following will be printed:

tom would be a jerk

Of course, can include end of line sequences in the replacemement pattern like this:

-r 'would\r\nbe\r\n'

Using this option, you would see the following output:

tom would
be
a jerk