Previous: utsmak Up: ../plot79_u.html Next: utsoma


UTSMAT

       INTEGER FUNCTION  UTSMAT (LINE,PAT,FIRST,LAST)
 C$    (MATCH - Regular Expression Pattern Match)
 C$    Given a  Software Tools  string,  LINE(*), and  an  encoded
 C$    regular expression pattern, PAT(*), constructed by  USTMAK,
 C$    return as  a function  value the  index in  LINE(*) of  the
 C$    first match, or 0  if no match was  found.  If there was  a
 C$    match, FIRST and LAST  are set to the  index in LINE(*)  of
 C$    the first and  last characters which  matched the  pattern.
 C$    FIRST will  always  be  identical to  the  function  value.
 C$    FIRST and LAST are both 0 if the match fails.
 C$
 C$    Most of the routines in  the UTS*** class are for  internal
 C$    use; the user-callable ones are
 C$
 C$    UTSH2S  - Convert  A1-format  Hollerith  array  to Software
 C$              Tools string; the  details are  described in  its
 C$              abstract.
 C$    UTSMAK  - Make a pattern from a regular expression string.
 C$    UTSMAT  - Search for a match of a pattern  from UTSMAK with
 C$              a Software Tools string.
 C$
 C$    If end-of-line pattern matching is to be used, care must be
 C$    taken to  insert the  NEWLIN value  immediately before  the
 C$    terminal EOS stored by UTSH2S.
 C$
 C$    A regular  expression  is  a  text pattern  made  up  of  a
 C$    concatenation of the following elements:
 C$
 C$    c        literal character c
 C$    ?        any character except newline
 C$    ^        beginning of line
 C$    $        end of line (null string before newline)
 C$    [...]    character class (any one of these characters)
 C$    [~...]   negated character class (all but these characters)
 C$    *        closure (zero or more occurrences of previous pattern)
 C$    @c       escaped character (e.g. @^, @$, @[, @*,)
 C$
 C$    Special meaning of  characters in  a text  pattern is  lost
 C$    when escaped, inside [...] (except for @]), or for:
 C$
 C$    ^        not at beginning of pattern
 C$    $        not at end of pattern
 C$    *        at beginning of pattern
 C$
 C$    A character class consists of zero or more of the following
 C$    elements, surrounded by [ and ]:
 C$
 C$    c        literal character c, including [
 C$    c1-c2    range of characters (digits, lower or upper case letters)
 C$    ~        negated character class if at beginning
 C$    @c       escaped characters (e.g. @~, @-, @@, @])
 C$
 C$    Special meaning of characters in a character class is  lost
 C$    when escaped or for:
 C$
 C$    ~        not at beginning
 C$    -        at beginning or end
 C$
 C$    An escape sequence consists of the character @ followed  by
 C$    a single character:
 C$
 C$    @n       newline
 C$    @N       newline
 C$    @t       tab
 C$    @T       tab
 C$    @c       c (include @@)
 C$
 C$    For example, to  find all  words beginning  with a  letter,
 C$    followed by zero or more letters or digits, and ending with
 C$    an "s":
 C$
 C$    [a-zA-Z][a-zA-Z0-9]*s[~a-zA-Z0-9]
 C$
 INCLUDE,L (KP Credit)
 C$    (13-SEP-84)