Since I mentioned the other routines, I wanted to post the results of some tests of the listed procedures.
There is a test program of the three
procedures that shows that if a NULL character is assumed otherwise not
used in the string and pattern and is appended that the glob() procedure
passes all tests, and the string_match() routine passes all tests except
for an issue with patterns composed completely of wildcard characters,
but that the match_wild procedure (surprisingly, as it has been available
from the Fortran Wiki for a long time as well as other sites) seems to
fail on a number of cases.
The string_match() procedure was altered to prevent undersubscripting
and oversubscripting but was not changed otherwise, although the fix
described above may reduce the failures when the null is not added. Have
not had time to try it yet.
At some point I want to add [a-b] character ranges and escaping if it does not have it
to one
of these (probably glob()) and/or make an interface to the C procedure fnmatch() if it is available on most platforms, so I wanted to look at
the currently available routines anyway; but since you mentioned you
used match_wild() I wanted to mention the preliminary results showed
some failures and that if appending a null is acceptable string_match()
works pretty well after all almost as-is except for the outlier with the
'*?' pattern so far.
The test program and procedures will be in
wget
http://www.urbanjost.altervista.org/REMOVE/match.tgz
for at least a few months with the test program and module (set up for
fpm(1) but pretty easy to just compile) for anyone interested. It seemed
a bit long to post. I do not see anything I did obviously wrong when
using string_match().
I got the same results with ifort, gfortran, and nvfortran compilers
tested so far.
Note also that there is a BRE (Basic Regular Expression) routine
in the GPF package at
https://github.com/urbanjost.
The significant output from the test is summarized below:
> >>>>>>>>>>>>>> METHOD 1: glob with //char(0)
> Passed
> >>>>>>>>>>>>>> METHOD 2: string_match with //char(0)
> Failed match on ab vs. *?
> Failed match on abc vs. *?
> Failed
> >>>>>>>>>>>>>> METHOD 3: match_wild with //char(0)
> Failed match on abcccd vs. *ccd
> Failed match on mississippi vs. *sip*
> Failed match on mississipissippi vs. *issip*ss*
> Failed match on mississippi vs. mi*sip*
> Failed match on ababac vs. *abac*
> Failed match on mississipPI vs. *issip*PI
> Failed match on bababa vs. b*ba
> Failed match on aaabbaabbaab vs. *aabbaa*a*
> Failed
> >>>>>>>>>>>>>> METHOD 4: glob
> Failed match on baaaaa vs. b*a
> Failed match on vs.
> Failed
> >>>>>>>>>>>>>> METHOD 5: string_match
> Failed match on ab vs. *?
> Failed match on abc vs. *?
> Failed match on a vs. *?
> Failed match on ab vs. ?*?
> Failed match on abc vs. ?**?*?
> Failed match on abcd vs. ?b*??
> Failed match on abcd vs. ?**?c?
> Failed match on abcde vs. ?*b*?*d*?
> Failed match on bLah vs. bLa?
> Failed match on bababa vs. b*ba
> Failed
> >>>>>>>>>>>>>> METHOD 6: match_wild
> Failed match on a*abab vs. a*b
> Failed match on abcccd vs. *ccd
> Failed match on mississippi vs. *sip*
> Failed match on mississipissippi vs. *issip*ss*
> Failed match on mississippi vs. mi*sip*
> Failed match on ababac vs. *abac*
> Failed match on mississipPI vs. *issip*PI
> Failed match on ab vs. *?*?*
> Failed match on abc vs. ?**?*?
> Failed match on abcde vs. ?*b*?*d*?
> Failed match on abcde vs. *e *
> Failed match on baaaaa vs. b*a
> Failed match on bababa vs. b*ba
> Failed match on b vs.
> Failed match on aaabbaabbaab vs. *aabbaa*a*
> Failed match on abc vs. ********a********b********c********
> Failed
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)