[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC] Case-preserving replacement sequence
From: |
Hu Jialun |
Subject: |
[RFC] Case-preserving replacement sequence |
Date: |
Tue, 19 Apr 2022 23:11:07 +0800 |
User-agent: |
Roundcube Webmail/1.3.11 |
Hello,
I would like to implement a new feature as detailed below, namely a new
backslash sequence in replacement for case-preserving replacement, and
would like to hear some comments before proceeding.
The sequence, which shall be denoted as \P tentatively, would be
followed by a capture group number, e.g. \P4. This would normalise the
capitalisation of following n characters (where n is the length of the
corresponding capture group) to that of the capture group. Such a
feature would supposedly offer a easier and faster way to do
case-preserving replacements than, say, a Perl script with replacement
callback.
As a trivial example,
$ sed 's/\(REGular\)/\P1expression/i' <<< "regular expression"
EXPression expression
$ sed 's/\(his\)\([[:punct:]]\)*\(word\)/\P1her\2\P3name/i' <<-EOF
his,word
His.WORD
his-wOrD
EOF
her,name
Her.NAME
her-nAmE
Any feedback would be greatly appreciated.
Many thanks,
Hu Jialun
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [RFC] Case-preserving replacement sequence,
Hu Jialun <=