Page 1 of 1

RegExp. Search for: and Replace with:

Posted: Mon Oct 05, 2020 7:31 pm
by sexy96
To rename files or directories in Total Commander
use the Multi-Rename Tool and such a pattern, e.g.

Polish letters:
Search for: ą|ć|ę|ł|ń|ó|ś|ź|ż
with: a|c|e|l|n|o|s|z|z

mąkę -> make

It must be very simple, I just don't know something.

In Notepad ++ works:
Search for: (ą)|(ć)|(ę)
with: (?1a)(?2c)(?3e)

How to do this in the text?

Posted: Mon Oct 05, 2020 10:08 pm
by opk44
sexy96
Use script "SearchReplace.js":

What:

Code: Select all

[ąćęłńóśźż]
With:

Code: Select all

return ("acelnoszz".charAt("ąćęłńóśźż".indexOf($0)));
Options:
[*] "Regular expressions"
[*] "Replace with function"

Save it as template with any name like "Polish_to_English"

Posted: Tue Oct 06, 2020 6:33 am
by sexy96
"Polish_to_English" Call("Scripts::Main", 1, "SearchReplace.js", `AkelPad.TextReplace(0, "[ąćęłńóśźż]", "return ("acelnoszz".charAt("ąćęłńóśźż".indexOf($0)));", 0x00480001 /*FRF_SELECTION|FRF_REGEXP|FRF_DOWN*/, 1);`) Icon("D:\WinCMD\Icons\2.ico")

Image

Posted: Tue Oct 06, 2020 1:19 pm
by opk44
sexy96 wrote:"Polish_to_English" Call("Scripts::Main", 1, "SearchReplace.js", `AkelPad.TextReplace(0, "[ąćęłńóśźż]", "return ("acelnoszz".charAt("ąćęłńóśźż".indexOf($0)));", 0x00480001 /*FRF_SELECTION|FRF_REGEXP|FRF_DOWN*/, 1);`) Icon("D:\WinCMD\Icons\2.ico")
"Jak sobie pościelesz, tak się wyśpisz."


Image

1. ToolBar button:
"Polish_to_English" Call("Scripts::Main", 1, "SearchReplace.js", `-Template="Polish_to_English"`) Icon("D:\WinCMD\Icons\2.ico")

2. The template "Polish_to_English" is stored in the "SearchReplace.ini" (codepage = UTF-16LE) file and looks like this:
...
Template8=Polish_to_English=what:/[ąćęłńóśźż]/ with:/return ("acelnoszz".charAt("ąćęłńóśźż".indexOf($0)));/rf
...

3. I don't know how to fix the problem with option "In_selection"

Posted: Tue Oct 06, 2020 3:17 pm
by sexy96
Thanks.
I would like to add before each character \

Find:
|()[]{}\

:
\|\(\)\[\]\{\}\\

Image

Posted: Tue Oct 06, 2020 6:47 pm
by opk44
sexy96
It is even easier.

1. In standard dialog "Replace..." {Ctrl+R}

What:

Code: Select all

([\|\(\)\[\]\{\}\\])
With:

Code: Select all

\\\1
Options:
[*] "Regular expressions"

2. In "SearchReplace.js" script:

What:

Code: Select all

([\|\(\)\[\]\{\}\\])
With:

Code: Select all

\$1
Options:
[*] "Regular expressions"

Posted: Wed Oct 07, 2020 5:49 am
by sexy96
Thank you very much. :D