1mNAME0m
       regexp - Match a regular expression against a string


1mSYNOPSIS0m
       1mregexp 22m?4mswitches24m? 4mexp24m 4mstring24m ?4mmatchVar24m? ?4msubMatchVar24m 4msubMatchVar24m 4m...24m?


1mDESCRIPTION0m
       Determines  whether  the  regular expression 4mexp24m matches part or all of
       4mstring24m and returns 1 if it does, 0 if it  doesn't,  unless  1m-inline  22mis
       specified  (see  below).   (Regular expression matching is described in
       the 1mre_syntax 22mreference page.)

       If additional arguments  are  specified  after  4mstring24m  then  they  are
       treated  as the names of variables in which to return information about
       which part(s) of 4mstring24m matched 4mexp24m.  4mMatchVar24m will be set to the range
       of  4mstring24m that matched all of 4mexp24m.  The first 4msubMatchVar24m will contain
       the characters in 4mstring24m that matched the leftmost parenthesized subex-
       pression  within  4mexp24m, the next 4msubMatchVar24m will contain the characters
       that matched the next parenthesized subexpression to the right in  4mexp24m,
       and so on.

       If  the  initial arguments to 1mregexp 22mstart with 1m- 22mthen they are treated
       as switches.  The following switches are currently supported:

       1m-about         22mInstead of attempting to match the  regular  expression,
                      returns  a list containing information about the regular
                      expression.  The first element of the list is  a  subex-
                      pression  count.   The second element is a list of prop-
                      erty names that describe various attributes of the regu-
                      lar  expression.  This  switch is primarily intended for
                      debugging purposes.

       1m-expanded      22mEnables use of the expanded  regular  expression  syntax
                      where  whitespace and comments are ignored.  This is the
                      same as specifying the 1m(?x) 22membedded option  (see  META-
                      SYNTAX, below).

       1m-indices       22mChanges  what is stored in the 4msubMatchVar24ms.  Instead of
                      storing the matching characters from 4mstring24m, each  vari-
                      able  will  contain a list of two decimal strings giving
                      the indices in 4mstring24m of the first and  last  characters
                      in the matching range of characters.

       1m-line          22mEnables newline-sensitive matching.  By default, newline
                      is a completely ordinary character with no special mean-
                      ing.   With  this flag, `[^' bracket expressions and `.'
                      never match newline, `^' matches an empty  string  after
                      any  newline in addition to its normal function, and `$'
                      matches an empty string before any newline  in  addition
                      to  its  normal  function.   This  flag is equivalent to
                      specifying both 1m-linestop 22mand 1m-lineanchor22m, or  the  1m(?n)0m
                      embedded option (see METASYNTAX, below).

       1m-linestop      22mChanges the behavior of `[^' bracket expressions and `.'
                      so that they stop at newlines.   This  is  the  same  as
                      specifying  the  1m(?p)  22membedded  option (see METASYNTAX,
                      below).

       1m-lineanchor    22mChanges the behavior of `^' and `$' (the ``anchors'') so
                      they match the beginning and end of a line respectively.
                      This is the same as specifying the 1m(?w) 22membedded  option
                      (see METASYNTAX, below).

       1m-nocase        22mCauses  upper-case characters in 4mstring24m to be treated as
                      lower case during the matching process.

       1m-all           22mCauses the regular expression  to  be  matched  as  many
                      times  as  possible  in  the string, returning the total
                      number of matches found.   If  this  is  specified  with
                      match  variables, they will continue information for the
                      last match only.

       1m-inline        22mCauses the command to return, as a list, the  data  that
                      would  otherwise  be  placed  in  match variables.  When
                      using 1m-inline22m, match variables may not be specified.  If
                      used  with  1m-all22m,  the list will be concatenated at each
                      iteration, such that a flat  list  is  always  returned.
                      For  each  match  iteration, the command will append the
                      overall match data, plus one element for each subexpres-
                      sion in the regular expression.  Examples are:
                          regexp -inline -- {\w(\w)} " inlined "
                       => {in n}
                          regexp -all -inline -- {\w(\w)} " inlined "
                       => {in n li i ne e}

       1m-start 4m22mindex24m   Specifies  a  character  index offset into the string to
                      start matching the regular expression  at.   When  using
                      this  switch,  `^'  will  not match the beginning of the
                      line, and \A will still match the start of the string at
                      4mindex24m.   If  1m-indices  22mis specified, the indices will be
                      indexed starting from  the  absolute  beginning  of  the
                      input  string.   4mindex24m will be constrained to the bounds
                      of the input string.

       1m--             22mMarks the end of switches.  The argument following  this
                      one will be treated as 4mexp24m even if it starts with a 1m-22m.

       If  there  are  more  4msubMatchVar24m's  than  parenthesized subexpressions
       within 4mexp24m, or if a particular subexpression in 4mexp24m doesn't  match  the
       string  (e.g. because it was in a portion of the expression that wasn't
       matched), then the corresponding 4msubMatchVar24m will be set to  ``1m-1  -122m''
       if 1m-indices 22mhas been specified or to an empty string otherwise.


1mSEE ALSO0m
       re_syntax(n), regsub(n)


1mKEYWORDS0m
