A little help with @REREPLACE

Jun 3, 2008
132
3
Temecula, CA
I'm rather weak with regular expressions, so please be gentle if I'm asking a rather simple question. What I want to be able to do is to take a file path of the form C:\WIP\E911\Aurora\branches\3.1_FED\Installer\Analytics.ism and change it to C:\WIP\E911\Aurora\main\Installer\Analytics.ism. The string to search will always be of the form <pre>\branches\<some branch>\<post>, and I want to replace the branches\<some branch> with main. So here's what I tried, and it sure looks right to me:

testit=for %f in (%$) echo %f %@rereplace[branches\\[^\\]+\\,main\\,%@quote[%@full[%f]]]

For the alias, I will supply one or more filenames that may be simple filenames, partial paths (such as dot-relative paths, like ..\test\myfile.txt, or maybe just of the form subdir\myfile.txt), or fully qualified paths. Using the %@quote[%@full[%f]] should cover all three of those cases. But my @rereplace isn't doing anything. My output is just the argument supplied followed by its full path, with no replacement having occurred. What do I have wrong?
 
May 20, 2008
11,530
102
Syracuse, NY, USA
Try doubling the '^'.
Code:
v:\> echo %@rereplace[branches\\[^^\\]+\\,main\\,a\branches\foo\bar]
a\main\bar
 
May 20, 2008
11,530
102
Syracuse, NY, USA
Thanks, Vince! Can you please explain why I need two up-arrows?
Not 100%. '^' is TCC's escape character. With only one, it's seen as escaping the '\'. Since '\' doesn't need escaping, the "^\" is just turned into '\'. So @REREPLACE sees "[\\]". "^^" means a literal '^', which what you want in the regular expression.

... or something like that.
 
Jun 3, 2008
132
3
Temecula, CA
Not 100%. '^' is TCC's escape character. With only one, it's seen as escaping the '\'. Since '\' doesn't need escaping, the "^\" is just turned into '\'. So @REREPLACE sees "[\\]". "^^" means a literal '^', which what you want in the regular expression.

... or something like that.

Of course! I handled the regular expression's escape but completely forgot about TCC's escape. Thanks! That will help me for the next time I do something like this.
 
Nov 8, 2015
27
1
or you can also do by side-stepping (redirecting) escape char into another less (or least) important char
setdos /e~ or setdos /e` or into any character you think the most rare uses with respect to the scope of characters usage, or you can just disable it for a while with setdos /x-8, then enable it later with setdos /x8
 
Jun 3, 2008
132
3
Temecula, CA
or you can also do by side-stepping (redirecting) escape char into another less (or least) important char
setdos /e~ or setdos /e` or into any character you think the most rare uses with respect to the scope of characters usage, or you can just disable it for a while with setdos /x-8, then enable it later with setdos /x8

Certainly a valid alternative. Thank you!
 
Similar threads
Thread starter Title Forum Replies Date
R How to? i need a little help Support 3
L A little startup help from an old CLI guy please. Support 14
H I need a little help. Support 4
Peter Murschall A little problem with LEAVE and COMMENT Support 5
M Little bug, big consequences .. Support 6
M An oddity that's a little bit scary... Support 6
vefatica ZIP /U a little screwy Support 9
M A little bit of strangeness with @Char... Support 3
M A new problem that has actually got me a little panicky... Support 10
Peter Bratton Another little bug? Support 1
A TCMD 11 little bugs Support 4
C Some little observations Support 16
C Add link to ewriter help to program group... Support 3
samintz How to? Search for %(command) in Help? Support 1
Joe Caverly Favorites in eWriter Help Support 6
Joe Caverly Quick Search in eWriter Help Support 1
vefatica Online help? Support 2
fishman@panix.com HELP!! I just updated to Version 28 and as usual I cannot make extended directory search work. Support 2
JohnQSmith New online help file wrong logo Support 7
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
Charles Dye More help nits Support 0
D Documentation Typo in COPY help Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
Joe Caverly Documentation COMMANDS in Version 27 help Support 8
K_Meinhard How to? Help window position Support 7
U Command help on file names Support 5
D Documentation Help "Startup" page does not describe global lists Support 0
vefatica Help disappears? Support 6
rchapmanitt Help Purchasing Support 2
Charles Dye Documentation Help nits: @ZIPFILECRC Support 0
C version help Support 3
C Documentation Help Nit. REN / RENAME Support 0
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
vefatica Help for @PID Support 2
vefatica Need help with XML Support 3
Alpengreis Documentation Minor issue in help file for view /E Support 1
R Documentation Advanced Directives Help Support 0
R Documentation Help Nit with SETP Support 0
R wmic command help Support 9
R Documentation Help Nit > bdebugger View Menu Support 0
R Documentation A couple of Help nits Support 0
R Documentation Help typo Support 1
MikeBaas How to? I need help with RD Support 5
R Documentation v25 Help Comments Support 1
Joe Caverly DIRectory Colorization in v25 Help File Support 0
vefatica Help nit Support 0
D error in help documentation? Support 0
Joe Caverly _EXPANSION in help file Support 0
K_Meinhard Help file error Support 1
Joe Caverly JOBMONITOR in Help File Support 1

Similar threads