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:
|
||||||||||
|
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
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation ("FICO"). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.
