Initializing help system before first use

regmatch

regmatch


Purpose
Compare text strings using a regular expression.
Synopsis
function regmatch(src:text, regex:string):boolean
function regmatch(src:text, regex:string, start:integer, flags:integer):boolean
function regmatch(src:text, regex:string, start:integer, flags:integer, mp:array(range) of textarea):boolean
Arguments
src 
Text to process
regex 
Regular expression
start 
Position where to start the search
flags 
Search options:
REG_EXTENDED 
Use Extended Regular Expression syntax (ERE), default is to interpret the expression as a Basic Regular Expression (BRE)
REG_ICASE 
Comparison is performed case insensitive (by default it is case sensitive)
REG_NEWLINE 
The character newline ( \n) is treated as the end of line (by default it is handled as an ordinary symbol)
REG_NOTBOL 
The beginning of the text string is not the beginning of a line
REG_NOTEOL 
The end of the text string is not the end of a line
mp 
Matching regions as an array of text area objects
Return value
true if a match was found.
Example
The following example extracts the value of 'pars2' from an input text consisting of lines of the form name=value:
declarations
 m:array(range) of textarea
 t:text
end-declarations

t:="p1=10\npars2=234\nparam9=56\n"
if regmatch(t,'pars2=\(.*\)$',1,REG_NEWLINE,m) then
 pars2:=parseint(t,m(1))
 writeln(pars2)
end-if
Further information
1. This function relies on the TRE library (see http://laurikari.net/tre). Please refer to the documentation of this library for a detailed description of the supported expression syntax.
2. When the mp argument is provided and the search is successful, the result of the processing is returned via this array as textarea objects (see Section The type textarea): the array cell 0 refers to the entire matching region and the following ones to each of the subexpressions.
Related topics
Module