[Lazarus] TMask revisited

José Mejuto joshyfun at gmail.com
Wed Oct 27 13:27:50 CEST 2021


El 26/10/2021 a las 18:48, Bart via lazarus escribió:
> On Tue, Oct 26, 2021 at 1:38 PM José Mejuto via lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
> 
>> You found a bug,

> 3. '-' if it is NOT the first char (or the first after the negating
> !), it is then the indicator for a range

Hello,

This is a side effect of the found bug, in ranges the only valid syntax 
(without sets enabled) is "char-char".

> So, even '*' is taken as a literal.

Escaping must work the same way (if possible) in all the mask, changing 
behaviour is not desirable as creates confusion. Sometimes when I write 
a mask in RegEx I escape some chars even when they are not needed to be 
escaped because it adds some clarity to the expression, cos if it is 
escaped I know for sure its a literal and no need to check if it matches 
a previous "[" or "{" or "(".

> A '?' in a range is forbidden (EMaskError: Invalid character "?" in
> mask), except for the [?].

It must be escaped to have meaning.

> Given this, I would think that:
> 1. escaping inside a range is not necessary: everything in a range is
> literal except for the 3 cases outlined above.
> 2. having a '?' could also be accepted as long as it is not the first
> character in the range specification, even [!?] could be allowed: any
> char but not a '?'.
> Point 2 would need (probably a minor) change to the CompileRange method.

With the last changed commited in GitHub (fixing the bug) escape would 
be necessary:

Macth strings "[Hell]" and "[Hell["
Mask: "*[\]\[]"

"]" must be escaped in all cases, with ranges and with sets or it will 
be interpreted as a premature closing (ranges).

-- 



More information about the lazarus mailing list