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'wouldbe'<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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
And you would like to replace "x<newline>is" with "would be". You can invoke .regex like this:
The following will be printed:
Of course, can include end of line sequences in the replacemement pattern like this:
Using this option, you would see the following output: