Sample

C Styled Script
Reference Manual

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using The CSS Executive
Language
Directives
System Library
String Library
Regular Expression Lib.
   Basic Matching Rules
   Additional Syntax Specs
   Order Of Precedence
   rexClose
   rexMatch
   rexOpen
   Sample
File Library
Database Library
C API
C++ API
CSS Links
  
#loadLibrary 'KcSysLib'
#loadLibrary 'KcStrLib'
#loadLibrary 'KcRexLib'
 
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 LandquartLast revised by Peter Koch, 24.02.00<< Back  Top  Next >>