version 0.2.2

Yann Mérignac (yann.merignac@laposte.net)

Wildcards is a pattern matching unit for Lazarus/Free Pascal. It provides a Match function to match a pattern against a string. If the pattern must be matched against several strings the unit provides a TWildcard class that is more efficient. Patterns may contain ?, *, [a-z] and other constructions (see Pattern Format).



This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules,and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>.


program PatMatch;

{$mode objfpc}{$H+}

uses Classes, SysUtils, Wildcrds;

procedure DoMatch(const Pattern, S: String);
  WriteLn('Match(''', Pattern, ''' , ''', S, ''') => ', Match(Pattern, S));

  DoMatch('p????l', 'pascal');
  DoMatch('p????l', 'free pascal');

  DoMatch('h*', 'hello');
  DoMatch('h*', 'Hello');

  DoMatch('[Ff]ree [Pp]ascal \D.\D.\D', 'Free Pascal 2.6.4');
  DoMatch('[Ff]ree [Pp]ascal \D.\D.\D', 'free pascal 2.6.4b');
  DoMatch('[Ff]ree [Pp]ascal \D.\D.\D', 'free pascal 2.6.4');

To run this program use :

user$ fpc patmatch
user$ ./patmatch

The result should be :

Match('p????l' , 'pascal') => TRUE
Match('p????l' , 'free pascal') => FALSE
Match('h*' , 'hello') => TRUE
Match('h*' , 'Hello') => FALSE
Match('[Ff]ree [Pp]ascal \D.\D.\D' , 'Free Pascal 2.6.4') => TRUE
Match('[Ff]ree [Pp]ascal \D.\D.\D' , 'free pascal 2.6.4b') => FALSE
Match('[Ff]ree [Pp]ascal \D.\D.\D' , 'free pascal 2.6.4') => TRUE


Documentation for the latest version is available here.


v0.2.2 (28/07/2015)

 - Changed: documentation format to Txt2FPDoc

v0.2.0 (29/07/2014)

 - First release