[UP]


Manual Reference Pages  - match (3)

NAME

match(3f) - [M_BRE] find match to a basic regular expression anywhere on input string (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Example
Author
Reference
License

SYNOPSIS

integer function match(line, pattern)

    character(len=*),intent(in) :: line
    integer,intent(in)          :: pattern(MAXPAT)

DESCRIPTION

Given a BRE(Basic Regular Expression) converted to a pattern return whether an input string matches it.

OPTIONS

LIN string to search for a match to the pattern
PAT pattern generated from a BRE using getpat(3f) or makpat(3f).

EXAMPLE

Sample program:

    program demo_match
    use :: M_BRE, only : getpat, match
    use :: M_BRE, only : MAXPAT, MAXARG, MAXLINE, YES, ERR
    implicit none
    ! find _ find patterns in text
    integer                      :: pat(MAXPAT)
    character(len=MAXARG-1)      :: argument
    integer                      :: stat
    integer                      :: ios
    integer                      :: len_arg
    character(len=MAXLINE-2)     :: line
    call get_command_argument(1, argument,status=stat,length=len_arg)
    if(stat.ne.0.or.argument.eq.’’)then
       write(*,*)"usage: find pattern."
    elseif(getpat(argument(:len_arg), pat) .eq. ERR) then
       write(*,*)"illegal pattern."
    else
       INFINITE: do
          read(*,’(a)’,iostat=ios)line
          if(ios.ne.0)exit
          if(match(trim(line), pat) .eq. YES) then
             write(*,’(*(a))’)trim(line)
          endif
       enddo INFINITE
    endif
    end program demo_match

AUTHOR

John S. Urban

REFERENCE

"Software Tools" by Kernighan and Plauger , 1976

LICENSE

Public Domain


match (3) March 11, 2021
Generated by manServer 1.08 from 511f1ed1-a43d-4fbb-bd3b-7ab37f9571ef using man macros.