Sample

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
  
#loadLibrary 'ZcSysLib'
#loadLibrary 'ZcStrLib'
#loadLibrary 'ZcRexLib'
 
main()
{
   const pattern = '\\(sim[a-z]le\\) \\1';
   const string  = 'a very simple simple simple string';
 
   sysLog('compile regular expression');
   var rx = rexOpen(pattern);
   var match[6][2];
 
   sysLog('find and display match');
   sysLogLevel(+1);
   var m = rexMatch(rx, string, 6, match);
   if (m) {
      for (var i = 0; i < m; i++)
         sysLog(
            match[i][0]+' '
            +match[i][1]+' \''
            +strSubString(string,match[i][0], match[i][1])
            +'\''
         );
   } else
      sysLog('no match found');
   sysLogLevel(-1);
 
   sysLog('close and release mem');
   rexClose(rx);
} // main

When executing this sample the output will be:

compile regular expression
find and display match
  8 13 'simple simple'
  8 6 'simple'
close and release mem
  Copyright © IBK Landquart Last revision: 27.05.2002 << Back  Top  Next >>