From 637fc27e86627239a5b5197a5e6669624443fab9 Mon Sep 17 00:00:00 2001 From: pgen Date: Tue, 23 Aug 2022 00:50:35 +0200 Subject: Improve and fix the substitution code --- smenu.1 | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'smenu.1') 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... \ -- cgit v1.2.3