flibs/strings(n) 1.1 "flibs"

NAME

flibs/strings - Glob matching

TABLE OF CONTENTS

    TABLE OF CONTENTS
    SYNOPSIS
    DESCRIPTION
    ROUTINES
    BUGS
    COPYRIGHT

SYNOPSIS

use glob_matching
matches = string_match( string, pattern)

DESCRIPTION

The glob_matching module provides a string matching method known as glob matching: it is used for instance under UNIX, Linux and DOS to select files whose names match a certain pattern - strings like "*.f90" describe all file swhose names end in ".f90".

The method implemented in the module is somewhat simplified than the full glob matching possible under UNIX: it does not support character classes.

Glob patterns are intended to match the entire string. In this implementation, however, trailing blanks in both the string and the pattern are ignored, so that it is a bit easier to use in Fortran.

The module supports both "*" and "?" as wild cards, where "*" means any sequence of characters, including zero and "?" means a single character. If you need to match the characters "*" or "?", then precede them with a backslash ("\"). If you need to match a backslash, you will need to use two:

 
    match = string_match( "c:\somedir" "c:\\*" )

will return .true., while:

 
    match = string_match( "c:\somedir" "c:\*" )

will not match, as the backslash "escapes" the asterisk, which then becomes an ordinary character.

ROUTINES

The module contains a single function:

use glob_matching
To import the glob matching function, use this module.

matches = string_match( string, pattern)
Check whether the (entire) string matches the given "glob" pattern. Trailing blanks in both the string and the pattern are ignored. The function returns .true. if the string matches the pattern, .false. otherwise.

character(len=*) string
The string to be examined

character(len=*) pattern
The string containing the pattern

BUGS

The matching algorithm is not flawless:

COPYRIGHT

Copyright © 2006 Arjen Markus <arjenmarkus@sourceforge.net>