Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Back-refs in TPIPE's /replace's replacement string?

May
12,929
170
Does anyone know if it's possible to specify SED-style back-refs in TPIPE's /replace's replacement string. Below, SED's replacement string "\1" refers to the first parenthesized regular expression found in the target string.
Code:
v:\> echo 1234 | sed  -e "s/.\(..\)./\1/g"
23
 
TPIPE does have some notion of (Perl) backrefs.
Code:
v:\> echo foo=foo | tpipe /replace=4,1,0,1,0,0,0,0,0,"(foo)=\1","bar"
bar
How do I specify a backref in a replacement string?
 
Does anyone know if it's possible to specify SED-style back-refs in TPIPE's /replace's replacement string. Below, SED's replacement string "\1" refers to the first parenthesized regular expression found in the target string.
Code:
v:\> echo 1234 | sed  -e "s/.\(..\)./\1/g"
23
Answer: Like this:
Code:
v:\> echo 1234 | tpipe /replace=4,1,0,1,0,0,0,0,0,".(..).","$1"
23

It might be a good idea for TPIPE's help to include a link to http://www.datamystic.com/textpipe/htmlhelp/general usage/regular_expressions.htm (and perhaps other documentation).
 

Similar threads

Back
Top