[SOLVED] TC Help: Documentation for regular expressions does not explain ? quantifier

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

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

[SOLVED] TC Help: Documentation for regular expressions does not explain ? quantifier

Post by *gdpr deleted 6 »

In TC's help about regular expressions, quantifiers such as * , + , {n} , {n,m} , etc. are explained in the section "Iterators".

However, an entry for the ? quantifier (the short form of {0,1}) is missing.

(Well, there is an explanation for the greediness modifier - which also uses the same symbol ?, but no explanation about the quantifier ?.)
Last edited by gdpr deleted 6 on 2021-03-12, 13:24 UTC, edited 1 time in total.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: TC Help: Documentation for regular expressions does not explain ? quantifier

Post by *ghisler(Author) »

I'm not aware of such an operator ? - are you sure it means the same as {0,1} ?
Author of Total Commander
https://www.ghisler.com
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: TC Help: Documentation for regular expressions does not explain ? quantifier

Post by *gdpr deleted 6 »

ghisler(Author) wrote: 2021-02-03, 14:49 UTC I'm not aware of such an operator ? - are you sure it means the same as {0,1} ?
Yes. Try it yourself...

For instance, given a text file with

Code: Select all

Hello
Hullo
Heello
a regex search with the pattern "e?llo" would select "ello" from "Hello", when continuing searching it would select "llo" from "Hullo", and then again "ello" from "Heello".


Or, if you prefer file name search, given four files:

Code: Select all

abc.txt
ac.txt
abbc.txt
adc.txt
a regex search with "ab?c" would find abc.txt and ac.txt, but not abbc.txt nor adc.txt.


The ? quantifier with the meaning of {0,1} is a common basic quantifier in most regex flavours. It is also documented on the TRegExpr website: https://regex.sorokin.engineer/en/latest/regular_expressions.html#quantification (although the wording "similar" for the *,+,? explanations chosen there is also a bit unfortunate, because these quantifiers are not just similar but equivalent to the mentioned {0,} , {1,} and {0,1} notations)
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: TC Help: Documentation for regular expressions does not explain ? quantifier

Post by *gdpr deleted 6 »

? quantifier now explained in help files for TC 10.00b1a (both english and german).

Thanks!
Post Reply