Recent

Author Topic: A question about "MatchesMask"  (Read 4394 times)

bonmario

  • Sr. Member
  • ****
  • Posts: 346
A question about "MatchesMask"
« on: November 10, 2011, 03:38:49 pm »
Hi,
Code: [Select]
MatchesMask('pplpw03', 'pplpw03');       ====> True
MatchesMask('pplpw03', 'pplpw??');       ====> True
MatchesMask('pplpw03', 'pplpw*');        ====> True
MatchesMask('pplpw03', 'pplpw??.*');     ====> False
MatchesMask('pplpw03', 'pplpw*.*');      ====> False

is correct that the result of last 2 MatchesMask is false or it's a bug?

Thanks, Mario

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: A question about "MatchesMask"
« Reply #1 on: November 10, 2011, 05:10:42 pm »
Correct.

In the 4th case, 'pplpw03' only matches up to 'pplpw??', while the mask still expects a '.' and optionally something else.

5th case is the same as 4, only the single character mask (?) is changed to 0 or more (non-greedy) character mask (*).

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: A question about "MatchesMask"
« Reply #2 on: November 11, 2011, 08:37:23 am »
Ok, i have a problem !!!

My program receive a list of file names. The user puts in a TEdit a mask for file names and the program must extract from the list only the files that matches the mask.
In the example of my first post, in all cases they must be extracted.

How can i do it?

Thanks in advance, Mario

Mando

  • Full Member
  • ***
  • Posts: 181
Re: A question about "MatchesMask"
« Reply #3 on: November 11, 2011, 11:05:19 am »
You can do this:

Code: [Select]
v:=MatchesMask('pplpw03', 'pplpw03');
v:=v or MatchesMask('pplpw03', 'pplpw??');
v:=v or MatchesMask('pplpw03', 'pplpw*');
v:=v or MatchesMask('pplpw03', 'pplpw??.*');
v:=v or MatchesMask('pplpw03', 'pplpw*.*');   



regards.


 

TinyPortal © 2005-2018