rexMatch

C Scripting Language
Reference Manual
Version 4.4.0

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using the CSL executive
Language
Directives
System library
String library
Math library
Regular expression lib.
   Basic matching rules
   Additional syntax specs
   Order of precedence
   rexClose
   rexMatch
   rexOpen
   Sample
File library
Database library
Async Communication
Registry/Profile handling
Windows control
C API
C++ Class Interface
CSL links
  
rexMatch(             // compile regular expression
   const handle,         // rex handle
   const string,         // string to match
   const nmatch,         // # of matches to find
   var &match[][],       // index & length of every match
  [const flags]);        // match flags

Compares the string against the compiled regular expression represented by handle to find a match between the two.

nmatch is the number of substrings in string that rexMatch should try to match with subexpressions in handle. The array you supply for match must have at least nmatch by 2 elements.

rexMatch fills in the elements of the array match with the starting index and the length of the matched substrings. The zeroth element of the array corresponds to the entire pattern. If there are more than nmatch subexpressions, only the first nmatch - 1 are stored.

If nmatch is 0, or if the rexOpenNosubreps flag was set when handle was created with rexOpen, rexMatch ignores the match argument and only returns 0 or 1 indicating if a match was found.

flags defines customizable behavior of rexMatch:

Flag Description
rexMatchNotbol Indicates that the first character of string is not the beginning of line.
rexMatchNoteol Indicates that the last character of string is not the end of line.

When a basic or extended regular expression is matched, any given parenthesized subexpression of the original pattern could participate in the match of several different substrings of string. The following rules determine which substrings are reported in pmatch:

  1. If a subexpression participated in a match several times, rexMatch stores index and length of the last matching substring in match.

  2. If a subexpression did not match in the source string, the number of matches returned is less than nmatch.

  3. If a subexpression contains subexpressions, the data in match refers to the last such subexpression.

If the rexOpenNosubreps flag was set when handle was created by rexOpen, the contents of match are unspecified. If the rexOpenNewline flag was not set when handle was created, new-line characters will not be treated as end-of-line.

Return value

If a match is found, rexMatch returns the number of matches including subreports. If no match is found rexMatch returns O.

  Copyright © IBK Landquart Last revision: 27.05.2002 << Back  Top  Next >>