Command: regexec

NEST HelpDesk Command Index NEST Quick Reference
Name:
regexec - compare string and regular expression
Synopsis:
regex string integer integer -> array integer
regex string 0 integer -> integer
Examples:
1) (simple) regcomp -> <regextype>
( simple ) 0 0 regexec -> 0 % this 0 indicating success
2) (simple) regcomp -> <regextype>
( simple ) 1 0 regexec -> [[3 9]] 0
% this 3,9 are begin and end offsets of matched regex!
3) ((parenthesize)+.*example) regcomp -> <regextype>
(This is a parenthesize using example) 2 0 regexec -> [[10 36] [10 22]] 0

4) This is a more complex example showing how more and more parenthesized
expressions are returned

/rx (:(passed|result|error):([0-9]+):(.*):) regcomp def
/st (:result:4:this is the result:) def

rx st 0 0 regexec -> 0
rx st 1 0 regexec -> [[0 29]] 0
rx st 2 0 regexec -> [[0 29] [1 7]] 0
rx st 4 0 regexec -> [[0 29] [1 7] [8 9] [10 28]] 0
Description:
regexec evaluates the given regular expression and looks whether it
is contained within a given string. It returns failure/success and the
offsets of the position where the regular expression was matched.
The same is true for any paranthesized subexpression: Those offsets are
stored in an array up to the chosen depth.
Flags and other codes REG_... are found in dictionary regexdict.
Parameters:
in: string is the string where te regular expression should be
looked for; regex is a regular expression generated by regcomp
first integer is the depth of paranthesized subexpression offsets
that should be returned,
second integer is a flag, for details see POSIX regexec
(set to zero if in doubt!)
out: integer is 0 if it matched, nonzero else (POSIX regexec error code)
array: an array of [beginoffset,endoffset] arrays indicating
the matches of the regex an any paranthesized subregexes within
the string.
Diagnostics:
no errors raised
Remarks:
See man regexec for further details on POSIX regexec.
Author:
Diesmann & Hehl
FirstVersion:
27.9.99
SeeAlso:
Source:
/var/www/debian/nest/nest-simulator-2.20.0/lib/sli/regexp.sli
NEST HelpDesk Command Index NEST Quick Reference

© 2004 The NEST Initiative