1. Computing & Technology
GlossaryTips/Tricks|FREE App/VCL|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit

MatchesMask

unit
Masks
category
type conversion routines
declaration
function MatchesMask(const StringToMatch, Mask: string): Boolean;
description
Returns True is a string value matches a format specifed by a mask.

The function raises an exception if the Mask parameter is syntactically invalid. Syntactically valid Mask consists of literal characters, sets, and wildcards.
Wildcards are asterisks (*) or question marks (?). An asterisk matches any number of characters. A question mark matches a single arbitrary character.
The comparison to literal characters is NOT case-sensitive.

example
const s = 'http://delphi.about.com';

MatchesMask(s,'h?p://*') == FALSE
MatchesMask(s,'h??p://*') == TRUE
MatchesMask(s,'http://*') == TRUE
MatchesMask(s,'http://*.com') == TRUE
MatchesMask(s,'http://*.net') == FALSE
MatchesMask(s,'*.about.com') == TRUE
MatchesMask(s,'about.com*') == FALSE
in real code
see also
IntToStr, SetLength, StrToBool


Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

Got some code to share? Got a question? Need some help?

Discuss in my forum

©2012 About.com. All rights reserved.

A part of The New York Times Company.