44     character(len = *), 
intent(in):: pattern
    45     integer, 
intent(out):: symbols(:)
    46     integer:: i, j, code, imax, j_last_set
    47     integer:: status, stat_return
    48     integer, 
parameter:: STAT_INIT = 1, stat_escape = 2, &
    49       stat_open_set = 3, stat_in_set = 4, stat_hexadecimal = 5
    53     stat_return = stat_init
    56     imax = len_trim(pattern)
    65         else if (c == 
"[") 
then    67           status = stat_open_set
    68         else if (c == 
".") 
then    70         else if (c == 
"?") 
then    72         else if (c == 
"+") 
then    74         else if (c == 
"*") 
then    76         else if (c == 
"^" .and. i == 1) 
then    78         else if (c == 
"$" .and. i == imax) 
then    84         if (c == 
'd' .or. c == 
'D') 
then    86         else if (c == 
'a' .or. c == 
'A') 
then    88         else if (c == 
'w' .or. c == 
'W') 
then    90         else if (c == 
's' .or. c == 
'S') 
then    92         else if (c == 
'z' .or. c == 
'Z') 
then    94         else if (c == 
'x' .or. c == 
'X') 
then    96           status = stat_hexadecimal
   102       case(stat_hexadecimal)
   103         code = index(
"123456789ABCDEFabcdef", c)
   104         if (code >= 16) code = code - 6
   105         if (symbols(j) == -1) 
then   109           symbols(j) = symbols(j) * 16 + code
   115         stat_return = stat_in_set
   123           symbols(j) = ichar(c)
   129           stat_return = stat_init
   136           symbols(j) = ichar(c)
   143       symbols(j) = ichar(
' ')
   153   recursive subroutine match_here(ipat, text, length)
   154     integer, 
intent(in):: ipat(:)
   155     character(len = *), 
intent(in):: text
   156     integer, 
intent(out):: length
   157     integer:: s1, s2, remain, i, hitmax, hitcount, hit_at_least
   161     if (
size(ipat) == 0 .or. ipat(1) == 
sym_eol) 
then   174     if (len(text) == 0) 
then   194     select case (ipat(s2 + 1))
   212       if (
hit(ipat(s1:s2), text(i:i)) .neqv. normal_hit) 
then   218     if (hitcount < hit_at_least) 
then   224     do, i = 1 + hitcount, 1 + hit_at_least, -1
   225       call match_here(ipat(remain: ), text(i: ), length)
   226       if (length >= 0) 
then   227         length = length + i - 1
   234   logical function hit(ipat, c) 
result(result)
   235     integer, 
intent(in):: ipat(:)
   236     character(len=*), 
intent(in):: c
   237     character(len=*), 
parameter:: &
   238       & DIGIT = 
"0123456789", &
   239       & XDIGIT = 
"ABCDEFabcdef", &
   240       & ALPHA = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"   243     do, i = 1, 
size(ipat)
   248         result = (index(alpha, c) > 0)
   250         result = (index(digit, c) > 0)
   252         result = (index(digit, c) > 0 .or. index(alpha, c) > 0 .or. &
   255         result = (index(digit, c) > 0 .or. index(xdigit, c) > 0)
   257         result = (c == 
' ' .or. (iachar(c) >= 8 .and. iachar(c) <= 13))
   259         result = (ipat(i) == ichar(c))
   266   subroutine match(pattern, text, start, length)
   321     character(len = *), 
intent(in):: pattern, text
   322     integer, 
intent(out):: start, length
   323     integer, 
allocatable:: ipattern(:)
   324     integer:: text_length
   327     if (len(pattern) <= 0) 
then   333     allocate(ipattern(len(pattern) + 2))
   339       if (length < 0) 
goto 995
   343     text_length = len(text)
   344     do, start = 1, text_length + 1
   345       call match_here(ipattern, text(start:text_length), length)
   346       if (length >= 0) 
goto 999
 integer, parameter sym_isword
 
integer, parameter sym_eol
 
integer, parameter sym_isxdigit
 
integer, parameter sym_isspace
 
integer, parameter sym_headfix
 
recursive subroutine match_here(ipat, text, length)
 
integer, parameter sym_isdigit
 
integer, parameter sym_count_base
 
シンプルな正規表現関数 'match' を提供します. 
 
subroutine preprocess_pattern(pattern, symbols)
 
integer, parameter sym_plus
 
subroutine, public match(pattern, text, start, length)
 
integer, parameter sym_star
 
integer, parameter sym_anychar
 
integer, parameter sym_question
 
integer, parameter sym_normal_set
 
integer, parameter sym_reversed_set
 
integer, parameter sym_isalpha
 
integer, parameter sym_tailfix
 
logical function hit(ipat, c)