Solved

String comparison

Posted on 2002-04-10
9
164 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
 
LVL 10

Expert Comment

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

Regards Jacco
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

15 Experts available now in Live!

Get 1:1 Help Now