1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
.TP
modify /\fIregex\fP/\fIreplace\fP/[ig]
.br
Sets the
.I modify
parameter for the
.IR "selected file" .
If a file has a modify parameter associated with it, each line selected
during a search will have that part of the line which matches
.I regex
(if any) replaced by the
.I replacement
string before being printed.
Like the
.I filter
command, the delimiter need not be\&\&/\&\&;
any non-space character is fine.
If a final\&\&i\&\&is given, the regex is applied in a case-insensitive
manner. If a final\&\&g\&\&is given, the replacement is done to all
matches in the line, not just the first part that might match
.IR regex .
The
.I replacement
may have embedded\c
.Q "\\1" ", "
etc. in it to refer to parts of the
matched text (see the tutorial on regular expressions).
The modify parameter, once set, may be enabled or disabled with
the other form of the modify command (described below).
It may also be temporarily toggled via the\c
.Q !m!
line prefix.
A silly example for the ultra-nationalist might be:
.nf
modify /<Japan>/Dainippon Teikoku/g
.fi
So that a line such as
.nf
[ˤ] /Bank of Japan/
would come out as
[ˤ] /Bank of Dainippon Teikoku/
.fi
As a real example of the modify command with
.IR kanjidic ,
consider that it is likely that one is not interested in all the
various fields each entry has. The following can be used to remove
the info on the U, N, Q, M, E, B, C, and Y fields from the output:
.nf
modify /( [UNQMECBY]\\S+)+//g,1
.fi
It's sort of complex, but works.
Note that here the
.I replacement
part is empty, meaning to just remove those parts which matched. The
result of such a search of would normally print
.nf
467c U65e5 N2097 B72 B73 S4 G1 H3027 F1 Q6010.0 MP5.0714
MN13733 E62 Yri4 P3-3-1 ˥ - - {day}
.fi
but with the above modify spec, appears more simply as
.nf
467c S4 G1 H3027 F1 P3-3-1 ˥ - - {day}
.fi
.TP
modify [\fIboolean\fP]
.br
Enables or disables the modify parameter for the
.IR "selected file" ,
or report the current status if no argument is given.
|