Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIKE Operator 2

Status
Not open for further replies.

GHolden

Programmer
May 28, 2002
852
GB
Hi,

Is there a Delphi equivalent for the VB Like operator. I want to be able to check to see if strings are in a particular format.

eg.

if StringVariable Like '[A-Z][0-9][ ][0-9][A-Z][A-Z]' then
//Do whatever

translates to...

if StringVariable is of the format Capital Letter, Number, Space, Number, Capital Letter, Capital Letter.

I realise that I can write my own, if one is not available.

Thanks.




There are two ways to write error-free programs; only the third one works.
 
Look at using a TMask - I think it will look something like this:
Code:
MyMask := TMask.Create('A0_0AA');
bIsMatch := (MyMask.Matches(MyString) and (MyString = UpperCase(MyString));
I haven't tested this but it looks like it should work.

-D
 
hilfy,

Fantastic !!

You've just fixed hours of fruitless searching.



There are two ways to write error-free programs; only the third one works.
 
Really a "star hint", hilfy!

buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top