summaryrefslogtreecommitdiffstats
path: root/smenu.1
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2022-08-23 00:50:35 +0200
committerpgen <p.gen.progs@gmail.com>2022-08-24 00:25:17 +0200
commit637fc27e86627239a5b5197a5e6669624443fab9 (patch)
tree185722598546478d8892f83e1c7485801b56b471 /smenu.1
parenta4a7a57956a39393f33039a6a78a48c4bf992f06 (diff)
Improve and fix the substitution code
Diffstat (limited to 'smenu.1')
-rw-r--r--smenu.129
1 files changed, 24 insertions, 5 deletions
diff --git a/smenu.1 b/smenu.1
index 6c4a49f..391c85b 100644
--- a/smenu.1
+++ b/smenu.1
@@ -1430,6 +1430,19 @@ Post-processes the words by applying a regular expression based
substitution.
The argument must be formatted as in the \fBsed\fP editor.
+As in \fBsed\fP, matching groups and references to these groups
+(from \f(CB\\0\fP to \f(CB\\9\fP in \fIrepl\fP) are supported.
+These groups must be surrounded by \f(CB(\fP and \f(CB)\fP in \fIregex\fP.
+\f(CB\\0\fP and \f(CB&\fP are equivalent in \fIrepl\fP as in the GNU
+version of \fBsed\fP.
+
+Back reference example:
+
+.nf
+\f(CBR=$(echo "[A] [B] [C]" | ./smenu -S '/([^][]+)/:\\1:/')\fP
+will display \f(CR"[:A:] [:B:] [:C:]"\fP
+.fi
+
This option can be used more than once.
Each substitution will be applied in sequence on each word.
This sequence can be stopped if a \fBstop\fP flag is encountered.
@@ -1451,14 +1464,20 @@ more substitution will be allowed on this word even if another
The optional trailing \fBi\fP (for \fIi\fPgnore case) means that the
string search operation should ignore the case for this pattern.
-Small example:
+Small examples to explain the meaning of \fIv\fP:
+
+.nf
\f(CBR=$(echo a b c | smenu -S /b/B/)\fP
-will display \f(CR"a B c"\fP and \f(CBR\fP will contain \fIB\fP if \fI
-B\fP is
-selected meanwhile
+.fi
+will display \f(CR"a B c"\fP and \f(CBR\fP will contain \fIB\fP
+when \fIB\fP is selected meanwhile
+
+.nf
\f(CBR=$(echo a b c | smenu -S /b/B/\fBv\fP)\fR
+.fi
will display the same as above but \f(CBR\fP will contain the original
-word \fIb\fP if \fIB\fP is selected.
+word \fIb\fP when \fIB\fP is selected.
+
In both cases, only the word \fIB\fP will be searchable and not \fIb\fP.
.RE
.IP "\fB-I\fP|\fB-si\fP|\fB-subst_included\fP... \