home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
csso0301.zip
/
SAMPLES
/
REX
/
REGULAR.CMD
Wrap
OS/2 REXX Batch file
|
2000-02-23
|
1KB
|
52 lines
@goto exec
/* Copyright (c) 2000 IBK-Landquart-Switzerland. All rights reserved.
*
* Module : Regular.cmd/Regular.bat
* Application : Sample showing use of regular expressions library
* and how to embedd CSS into a CMD or BAT file.
* Author : Peter Koch, IBK
*
* Date Description Who
* --------------------------------------------------------------------------
* Feb 2000 First release P.Koch, IBK
*/
#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
/*
* This section is run by the command processor. We start the
* CSS executive here and pass any parameters.
*
:exec
@css %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
@rem */