Solved

String comparison

Posted on 2002-04-10
9
166 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now