Solved

String comparison

Posted on 2002-04-10
9
167 Views
Last Modified: 2012-05-04
well i need some function, wich could compare two strings.

but i do not need to know, if they are equal, but if they are similar by using asterisk convention.

for example: string *abc is similar, but not equal to dabc.

is any api for it? i mean when windows are searching for a file like 'wi*.com', it will find 'win.com' and much more files with similar name. there should be any api, else it would be so relatively quickly.
0
Comment
Question by:pistacer
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:dMa
ID: 6930655
API
int CompareString(
    LCID Locale,     // locale identifier
    DWORD dwCmpFlags,     // comparison-style options
    LPCTSTR lpString1,     // pointer to first string
    int cchCount1,     // size, in bytes or characters, of first string
    LPCTSTR lpString2,     // pointer to second string
    int cchCount2      // size, in bytes or characters, of second string  
   );    
 
but it's not doing exactly what your are needed ..... or?
0
 

Author Comment

by:pistacer
ID: 6930682
well, from the help i do not know ... i mean i need fction, wich would say:
yes, '*abc' is similar to 'dabc'
and yes, '*abc' is similar to 'bbbabc'
0
 

Author Comment

by:pistacer
ID: 6930688
well, from the help i do not know ... i mean i need fction, wich would say:
yes, '*abc' is similar to 'dabc'
and yes, '*abc' is similar to 'bbbabc'
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 10

Expert Comment

by:Jacco
ID: 6930703
You need something like regexp.

Regards Jacco
0
 

Author Comment

by:pistacer
ID: 6930706
wow, and what is it 'regexp' please?
0
 
LVL 2

Expert Comment

by:dMa
ID: 6930717
regexp = regular expression notation
0
 
LVL 17

Accepted Solution

by:
geobul earned 100 total points
ID: 6930725
Hi,
---
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses Masks;

function StringMatch(const Value, Mask: string): boolean;
var
  oMask: TMask;
begin
  oMask := TMask.Create(Mask);
  try
    result := oMask.Matches(Value);
  finally
    oMask.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if StringMatch(Edit1.Text,Edit2.Text) then ShowMessage('Match')
    else ShowMessage('Do not match');
end;

end.
---

Edit1 is the string to be verified (ex:dddabc) and Edit2 is the mask (ex:*abc).

Regards, Geo
0
 

Author Comment

by:pistacer
ID: 6930762
bingo!

simple and effective!

thanks wery much!!
0
 
LVL 17

Expert Comment

by:geobul
ID: 6930808
You are welcome

Regards, Geo
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 191
Press three keys together and trigger a function 3 60
Delphi: sending SMS on android platform 1 32
MS Access from Delphi 31 59
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question