# A little help with @REREPLACE

#### MickeyF

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?

#### vefatica

Try doubling the '^'.
Code:
v:\> echo %@rereplace[branches\$^^\$+\\,main\\,a\branches\foo\bar]
a\main\bar

#### MickeyF

Try doubling the '^'.
Code:
v:\> echo %@rereplace[branches\$^^\$+\\,main\\,a\branches\foo\bar]
a\main\bar

Thanks, Vince! Can you please explain why I need two up-arrows?

#### vefatica

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.

#### MickeyF

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.

#### Budi

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

#### MickeyF

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!

Replies
3
Views
2K
Replies
14
Views
3K
Replies
4
Views
3K
Replies
5
Views
1K
Replies
6
Views
1K
Replies
6
Views
1K
Replies
9
Views
2K
Replies
3
Views
1K
Replies
10
Views
3K
Replies
1
Views
2K
Replies
4
Views
3K
Replies
16
Views
6K
Replies
3
Views
204
Replies
1
Views
230
Replies
6
Views
262
Replies
1
Views
208
Replies
2
Views
199
Replies
2
Views
280
Replies
7
Views
295
Replies
0
Views
193
Replies
0
Views
225
Documentation Typo in COPY help
Replies
0
Views
314
Replies
7
Views
547
Replies
8
Views
679
Replies
7
Views
500
Replies
5
Views
534
Replies
0
Views
359
Replies
6
Views
609
Replies
2
Views
432
Documentation Help nits: @ZIPFILECRC
Replies
0
Views
359
Replies
3
Views
533
Documentation Help Nit. REN / RENAME
Replies
0
Views
432
Replies
0
Views
488
Replies
2
Views
510
Replies
3
Views
607
Replies
1
Views
667
Replies
0
Views
521
Documentation Help Nit with SETP
Replies
0
Views
555
Replies
9
Views
2K
Replies
0
Views
581
Documentation A couple of Help nits
Replies
0
Views
612
Documentation Help typo
Replies
1
Views
1K
Replies
5
Views
967
Replies
1
Views
623
Replies
0
Views
557
Replies
0
Views
601
Replies
0
Views
602
Replies
0
Views
558
Replies
1
Views
627
Replies
1
Views
779