Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

Ответ
 
Опции темы Поиск в этой теме Опции просмотра
  #16  
Старый 22.01.2009, 23:08
randy randy вне форума
Прохожий
 
Регистрация: 18.01.2009
Сообщения: 14
Репутация: 10
По умолчанию

thank you Vayrus , Although i don't understand what you're saying , But to understand the Word WildCard see this Link


many thanks
Ответить с цитированием
  #17  
Старый 22.01.2009, 23:24
ART ART вне форума
Продвинутый
 
Регистрация: 13.02.2006
Адрес: Магнитогорск
Сообщения: 669
Репутация: 14745
По умолчанию

Цитата:
Сообщение от Vayrus
> wildcards - поиск по шаблону

Я же уже говорил что это и как эту проблему решить, почему люди не читают ответы И Я поражаюсь, как люди программируют, не зная что такое wildcards
Ладно ты здесь один такой умный, что всем разъяснил. Поиски по шаблону существуют разные и можно успешно программировать о многом незная.
Ответить с цитированием
  #18  
Старый 22.01.2009, 23:49
ART ART вне форума
Продвинутый
 
Регистрация: 13.02.2006
Адрес: Магнитогорск
Сообщения: 669
Репутация: 14745
По умолчанию

randy, возможно, тебе поможет функция matchesmask в модуле masks. Можешь посмотреть реализацию этой функции в этом модуле и сделать что нибудь свое, подходящее под твою задачу
Ответить с цитированием
  #19  
Старый 22.01.2009, 23:58
randy randy вне форума
Прохожий
 
Регистрация: 18.01.2009
Сообщения: 14
Репутация: 10
По умолчанию

Where can i find matchesmask in the FAQ give me the Link


Russian ( Google Translate ) :

Где я могу найти matchesmask в FAQ дайте мне ссылку?
Ответить с цитированием
  #20  
Старый 23.01.2009, 00:21
Аватар для Vayrus
Vayrus Vayrus вне форума
Исполняемый Ретровирус
 
Регистрация: 09.08.2008
Адрес: Umbrella Corporation
Сообщения: 743
Репутация: 1293
По умолчанию

See Delphi Help

Add Unit Masks In Your Project.

Delphi syntax:
function MatchesMask(const Filename, Mask: string): Boolean;

Description
Call MatchesMask to check the Filename parameter using the Mask parameter to describe valid values. A valid mask consists of literal characters, sets, and wildcards.
Each literal character must match a single character in the string. The comparison to literal characters is case-insensitive.
Each set begins with an opening bracket ([) and ends with a closing bracket (]). Between the brackets are the elements of the set. Each element is a literal character or a range. Ranges are specified by an initial value, a dash (-), and a final value. Do not use spaces or commas to separate the elements of the set. A set must match a single character in the string. The character matches the set if it is the same as one of the literal characters in the set, or if it is in one of the ranges in the set. A character is in a range if it matches the initial value, the final value, or falls between the two values. All comparisons are case-insensitive. If the first character after the opening bracket of a set is an exclamation point (!), then the set matches any character that is not in the set.
Wildcards are asterisks (*) or question marks (?). An asterisk matches any number of characters. A question mark matches a single arbitrary character.
MatchesMask returns true if the string matches the mask. MatchesMask returns false if the string does not match the mask. MatchesMask raises an exception if the mask is syntactically invalid.
Note: The Filename parameter does not need to be a file name. MatchesMask can be used to check strings against any syntactically correct mask.

Последний раз редактировалось Vayrus, 23.01.2009 в 00:27.
Ответить с цитированием
  #21  
Старый 23.01.2009, 00:43
randy randy вне форума
Прохожий
 
Регистрация: 18.01.2009
Сообщения: 14
Репутация: 10
По умолчанию

MatchesMask Is using when you want to compare between FileNames :

Like This :

const s = 'http://www.delphisources.ru';

MatchesMask(s,'h?p://*') == FALSE
MatchesMask(s,'h??p://*') == TRUE
MatchesMask(s,'http://*') == TRUE
MatchesMask(s,'http://*.ru') == TRUE
MatchesMask(s,'http://*.net') == FALSE


But what i'm doing is Looking in Strings not Files .




That's why i used the FastPos from the FastStrings .

I will show you here :

if (FastPos( s,
lVirus^.Signature,
sLen,
lVirus^.SigLen, 1) > 0) then
result := gSignatures.IndexOf(lVirus);


S: is the Buffer i'm searching In .
lVirus^.Signature : is the Pattern i'm using ( Virus Signature )
sLen : the Buffer Length i'm searching in this will narrow the Pattern and fasten the scanning.
lVirus^.SigLen: the Virus Signature Length , why i use it because if we find a Virus with a 255 Signature then don't use this Length for all othere Viruses , but Use an othere Signature Length .
1: Is the Default Start Point in FastPos in FastStrings otherwise you will get nothing .



Many thanks .

Последний раз редактировалось randy, 23.01.2009 в 00:53.
Ответить с цитированием
  #22  
Старый 23.01.2009, 10:56
DungeonLords DungeonLords вне форума
Активный
 
Регистрация: 21.07.2008
Сообщения: 257
Репутация: 14
По умолчанию

Не понял, чё он написал. То ли вопрос, то ли ответ.

Ну если примерно, то первой строчкой он сообщает нам, что

"MatchesMask" используется для сравнения между "FileNames"

//But what i'm doing is Looking in Strings not Files .
Но что я делаю смотря в строку без файла.(Да перевод слишком примерный)

//That's why i used the FastPos from the FastStrings .
Поэтому я использую "FastPos" из "FastStrings"

//I will show you here :
Я покажу вам на примере:
if (FastPos( s,lVirus^.Signature,sLen,lVirus^.SigLen, 1) > 0) then result := gSignatures.IndexOf(lVirus);

"S" - это буфер, в который он прописывает результаты поиска
"lVirus^.Signature" - это образец, который я использую (* - примечание переводчика - "вроде как специальный тип")
"sLen" - тоже буфер, в который я использую для более конкретного образца и быстрого сканирования файлов
"lVirus^.SigLen" - длина электронной цифровой подписи вируса, зачем я её использую, потому что если я найду 255 цифровых подписей, то нельзя будет использовать эту длину подписи для всех вирусов, но ...(* примечание переводчика - не понял)

1: это детальная точка старта в "FastPos" в "FastStrings", иначе ты можешь ничего не получить.

Спасибо, спасибо, спасибо .


Мне нечего написать по теме, перевёл для себя, и чтобы другие "англичане" не тратили время на примерный перевод


P.S. Randy, you don't written thanks for me. I don't written anything very good. Better, sad thanks for Vayrus.

Последний раз редактировалось DungeonLords, 23.01.2009 в 11:25.
Ответить с цитированием
  #23  
Старый 23.01.2009, 12:13
Аватар для Vayrus
Vayrus Vayrus вне форума
Исполняемый Ретровирус
 
Регистрация: 09.08.2008
Адрес: Umbrella Corporation
Сообщения: 743
Репутация: 1293
Лампочка

Я так понял что ему надо сканировать по маске еще и файлы в сети, поправьте если ошибаюсь

You it is necessary to scan the files in network ???
Ответить с цитированием
  #24  
Старый 23.01.2009, 12:50
ART ART вне форума
Продвинутый
 
Регистрация: 13.02.2006
Адрес: Магнитогорск
Сообщения: 669
Репутация: 14745
По умолчанию

Ему походу надо работать не именами файлами, а с текстом, если не ошибаюсь.

Код:

//T  -  text; M  -  mask; Sp  -  StartPos; result  -  position (index) in text
//if Substr is not found,  function returns zero.
function MatchesMaskEx(T,  M: string; Sp: integer): integer;
var
  Tl,  Ml: integer; // length of file name and mask
  Tp,  Mp: integer; // pointers
  first: boolean;
begin
  T  :=  UpperCase(T);
  M  :=  UpperCase(M);
  result  :=  0;
  Tl  :=  length(T);
  Ml  :=  length(M);
  Tp  :=  Sp;
  Mp  :=  1;
  first  :=  false;
  while Mp  <=  Ml do
  begin // wildcard
    case M[Mp] of //
      '?':
        begin // if one any char
          inc(Mp); // next char of mask
          inc(Tp); // next char of file name
        end; //
      ' * ':
        begin // if any chars
          if Mp  =  Ml then
            exit; // if last char in mask then exit
          if M[Mp  +  1]  =  T[Tp] then
          begin // if next char in mask equate char in
            Inc(Mp); // file name then next char in mask and
          end
          else
          begin // else
            if Tp  =  Tl then
            begin // if last char in file name then
              result  :=  0; // function return false
              exit; //
            end; // else,  if not previous,  then
            inc(Tp); // next char in file name
          end; //
        end; //
    else
      begin // other char in mask
        if M[Mp]  <>  T[Tp] then
        begin // if char in mask not equate char in
          Mp  :=  1;
          first  :=  false;
          continue;
        end; // else
        if (Mp = Ml) and (Tp <> Tl) then begin
        Result := 0;
        exit;
       end;
        if first  =  false then begin
         first  :=  true;
         Result  :=  Tp;
        end;
        inc(Tp); // next char of mask
        inc(Mp); // next char of file name
      end
    end;
  end;
end;
Ответить с цитированием
  #25  
Старый 23.01.2009, 21:39
randy randy вне форума
Прохожий
 
Регистрация: 18.01.2009
Сообщения: 14
Репутация: 10
По умолчанию

Цитата:
Сообщение от Vayrus
Я так понял что ему надо сканировать по маске еще и файлы в сети, поправьте если ошибаюсь

You it is necessary to scan the files in network ???


Of Course my friend .
Ответить с цитированием
  #26  
Старый 23.01.2009, 22:44
Аватар для Vayrus
Vayrus Vayrus вне форума
Исполняемый Ретровирус
 
Регистрация: 09.08.2008
Адрес: Umbrella Corporation
Сообщения: 743
Репутация: 1293
Лампочка

Наверно криво написал

Speak to BlackCash, he has too written antiviruses, can he will help you.
Ответить с цитированием
  #27  
Старый 23.01.2009, 23:20
randy randy вне форума
Прохожий
 
Регистрация: 18.01.2009
Сообщения: 14
Репутация: 10
По умолчанию

I'm Looking for him , if i find him i will kill him
Ответить с цитированием
Ответ


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 23:27.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2025