libsim  Versione6.3.0
Membri pubblici | Elenco di tutti i membri
Riferimenti per l'nterfacciamatch

Tries to match the given string with the pattern Result: .true. Continua...

Membri pubblici

recursive logical function string_match (string, pattern)
 Tries to match the given string with the pattern. Continua...
 
logical function, dimension(size(string)) string_match_v (string, pattern)
 Tries to match the given string with the pattern (array version). Continua...
 

Descrizione dettagliata

Tries to match the given string with the pattern Result: .true.

if the entire string matches the pattern, .false. otherwise Note: Trailing blanks are ignored

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.

BUGS

The matching algorithm is not flawless:

Definizione alla linea 393 del file char_utilities.F90.


Generated with Doxygen.