Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 702077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:40:50+00:00 2026-05-14T03:40:50+00:00

I have been experimenting with TMask in Delphi 2010 and it seems to work

  • 0

I have been experimenting with TMask in Delphi 2010 and it seems to work as expected except in one situation: when the mask name contains [ or ] the mask always seem to return false. For example:

var
  MaskObj : TMask;
begin
  MaskObj:= TMask.Create('c:\[test]\*');
  try
    Result:= MaskObj.Matches('c:\[test]\text');
  finally
    FreeAndNil(MaskObj);
  end;
end;

returns false. …

Yes, [ and ] are legal characters in file name. So if I want to exclude for example all files in c:[test]*, what could I do here? My only solution is to do a StringReplace if [ is detected, but this will be slow for a large number of files:

if (pos('[', Mask)>0) then
begin
  mask:= ReplaceString(Mask, '[','_', etc...
  // and do the same for the file name---
end;

Is there any other approach?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:40:51+00:00Added an answer on May 14, 2026 at 3:40 am

    ‘[‘ is used to mark the beginning of a set of characters (eg, “[A-Z]”). In order to match ‘[‘ on its own you just need to create it as its own single-character set. ‘]’ doesn’t need to be similarly escaped, since it’s only a special character once a leading ‘[‘ is found. Try C:\[[]test]\*

    Edit:

    If you’re allowing arbitrary masks you’ll need to use StringReplace(Mask, '[', '[[]', [rfReplaceAll]) for the mask, but not for the filenames. If you never use the [a-z] wildcards I’d just descend from TMask and handle it in the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been experimenting with using javascript to dynamically write stylesheets. In Firefox, one
For fun I have been experimenting with methods of encryption. One of the methods
I have been experimenting a lot with some glassy images, such as the one
I have been experimenting with woopra.com A web analytics tool. Which requires a piece
I have been experimenting with WPF and rendering strict XAML markup in a web
I have been experimenting with Lambda expressions in Oxygene. Very simple recursive lambda expression
I have been experimenting with a lot of web development apps like Drupal, Moodle,
I have been experimenting with writing applications that use a local SQL Database to
I have been experimenting with sending messages from two .NET Windows Forms applications using
I have been experimenting some problems with the fully distributed version. First of all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.