Multirename tool: computed range instead of fixed range

English support forum

Moderators: Hacker, petermad, Stefan2, white

gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

Stefan2 wrote:Milo, you don't have to "guess".
If you enable RegEx, then the regex engine is active for the "replacement scheme",
and so the mentioned help about the regex syntax can be used.
Milo is correct, but you also have a point. This exchange between you two here is a good example of why the help about the regular expressions needs to be improved.

The problem is that the help talks about both regular expression syntax AND the replacement string syntax on the same page in a very ambiguous manner.

The help has one paragraph titled "Escape sequences", and it is not quite clear whether this is about the regex syntax only or about both the regex syntax and the replacement string syntax. After all, the same help talks somewhere in the middle of the page about $1..$32 patterns for the replacement string (which obviously are not element of a regular expression), only to return to regex syntax in the following paragraph. It is rather all mixed up, making it hard for people to understand.

Now, for those among us who are familiar with regular expressions will realize quickly that this or that piece of information only applies to regular expressions but not to the replacement string patterns. But even with this knowledge... Note, how the "Escape sequences" paragraph explains escape sequences like \xNN (character as hex code). Something that would certainly make complete sense in a replacement string too. But does it actually work in a replacement string? According to your comment, it should. But hey, go and try it out... (Hint: No, it doesn't work... ;) )

That means, Milo is correct with his assessment. But i don't blame you either, Stefan2, because the documentation is a bit of a mess, and the only way to figure out what is or what is not working is simply to try and see what happens. Not trying to blow a small issue out of proportion, but the documentation could benefit from some loving attention...
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Some point picked out:

-- "the replacement string syntax" (and the search also) becomes "regex syntax" once you enable [X]RegEx.

-- "$1..$32 patterns" (or the \1 equivalent) are "element of a regular expression"

-- "\xNN" as e.g. "\x20" works as search string.
Nothing mentioned that it should work in replacement, which I have nowhere seen anyway. Would there be an use for this?


So the help is right.
(Also please note, that the regex is used not only for MRT,
so the help may explain things not working in MRT, but perhaps elsewhere)


All that academic explanation what RE is on default and on itself is useless here,
as C.G. has already taking care to implement it in a way the user can use it.
Just enable [X]RegEx and us regex syntax in the search and the replace box.


Tip: write up an alternatively help for RegEx used in TC (best with examples)
Perhaps Christian can use it to improve his help. Or at least you can point users to your advanced help.



 
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

Stefan2 wrote:-- "the replacement string syntax" (and the search also) becomes "regex syntax" once you enable [X]RegEx.

-- "$1..$32 patterns" (or the \1 equivalent) are "element of a regular expression"
No, no. They are not elements of a regular expression. You probably thought of

Code: Select all

s/regex/replacement_string/
as a regular expression, right? The thing is, only the part labelled as regex there (nomen est omen) is a regular expression. The whole s/.../.../ construct is what is called a regex substitution or a replacement pattern. A regex subsitution requires a regex, but the regex substitution itself is not a regex. The replacement string in a regex substitution is not a regex, either.
-- "\xNN" as e.g. "\x20" works as search string.
Nothing mentioned that it should work in replacement, which I have nowhere seen anyway.
You did. (read Milo's 2nd post and your follow-up again). That was the point i was trying to make with the \xNN example -- that regex escape sequences are not working in replacement strings, and hence the help about regex language elements is not really applicable to the replacement string syntax.

Probably this was not your intention, but your arguments with respect to regular expressions and replacement strings have been confusing, so it is really unclear what you are intending to communicate...
Would there be an use for this?
With regard to its usefulness you are probably right. Thinking a little bit harder about it, its utility value would be rather small since one could easily use Alt+Numberpad to enter characters by their (decimal) code point and thus would not really require \xNN or \x{NNNN}. The reasons of why i did choose this escape sequence as example still stand, however. (i.e.; the help about regex syntax is not applicable to replacement strings; see the paragraph above... ;) )
So the help is right.
What exactly do you mean? Do you mean that the help is right because it does not mention \xNN is working in replacement strings? If so, well, bad news for you: Your argument is built on very, very thin ice.

Note that the help also does not mention that \[ or \. should work in replacement strings. But they do work in replacement strings. According to your "logic" they should not work in replacement strings if the help is not mentioning it. That is not really being in favor of your argument here, isn't it? Yeah, the help is a backstabbing bitch... :wink:
All that academic explanation what RE is on default and on itself is useless here, as C.G. has already taking care to implement it in a way the user can use it. Just enable [X]RegEx and us regex syntax in the search and the replace box.
Yeah, all those "academic" explanations are just so confusing and it is all so complicated and does not make sense, right...? :lol:
Tip: write up an alternatively help for RegEx used in TC (best with examples) Perhaps Christian can use it to improve his help. Or at least you can point users to your advanced help.
Oh, no! You did not! You did not bring the godmother of all arguments to the table, did you? I cannot argue against the godmother of all arguments. Nobody ever did and saw the light of the new day. I have to admit defeat. My arguments are worthless. You are right, you are so right. How could i ever have doubted you... Have mercy!

That said, it should be doable on a rainy boring afternoon. No promises, though. I know that CHM is using some HTML flavor for the page layout, so that should be rather simple. But i never did much with respect to CHM authoring and compiling, so i don't know how much pain it would be to get a simple CHM toolchain rolling and steaming... ;)
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Related to your edit:


Just select your HTML files, press Alt+F5 and chose CHM.





http://totalcmd.net/plugring/chmdir.html


Usually, I just rename my HTML file with leading numbers in the order I want them in the CHM help file.
Next I select all HTML files, press Alt+F5 and chose CHM, and the CHM is created in the other pane.
That was the simplest way I could find without fiddling around with contents, index, etc. hhc, hhk, hhp files.
Of course that way we miss all the advanced feature like 'sub topics' and search. But for just a few pages that should be just fine.




HTH?
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

Stefan2 wrote:Related to your edit:

Just select your HTML files, press Alt+F5 and chose CHM.

http://totalcmd.net/plugring/chmdir.html
I did that already :) Saw in the HTML headers that Christian uses HelpScribble to generate the CHM pages. Would probably a good idea to use the same tool, unless HelpScribble is good enough to properly accept and process formatted text copy'n'pasted from a hand-crafted HTML document (including any links/references to other pages in the CHM project; which i guess could be somewhat troublesome...). But i haven't looked at HelpScribble yet except of a cursory visit to its website. Still waiting for the rain... ;)
Post Reply