Solved

String comparison

Posted on 2002-04-10
9
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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