Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

pcreMatchList

pcreMatchList( 
g_pattern 
l_subjects 
[ x_compOptBits ] 
[ x_execOptBits ]
) 
=> l_results / nil / error message(s)

Description

Matches a list of subjects (strings or symbols) against a regular expression pattern (g_pattern) and returns a list of those elements that match. You can use optional arguments to specify independent option bits for controlling pattern compiling and matching. The compiling and matching algorithms are PCRE/Perl-compatible.

The specified regular expression pattern overwrites the previously-compiled pattern and is used for subsequent matching until you provide a new pattern. The function reports any errors in the given pattern.

You can set and unset the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and PCRE_EXTENDED independent option bits from within the pattern. The content of the options argument specifies the initial setting at the start of compilation. You can set the PCRE_ANCHORED option at matching time and at compile time.

If pcreObject is specified as the g_pattern, pcreMatchList skips pattern compilation and ignores x_compOptBits.

Arguments

g_pattern

String containing regular expression string to be compiled or a pcreObject.

l_subjects

List of subject strings or symbols to be matched against the regular expression string. If it is a symbol, its print name is used.

x_compOptBits

(Optional) Independent option bits that affect the compilation. Valid values for this argument are the same as those for the x_options argument to the pcreCompile SKILL function.

x_execOptBits

(Optional) Independent option bits that affect pattern matching. Valid values for this argument are the same as those for the x_options argument to the pcreExecute SKILL function.

Value Returned

l_results

List of strings, symbols, or PCRE objects from the subject list that match the pattern.

nil

No matches or match failure.

error message(s)

Zero or more error messages that appear if the function fails for any reason, if the subject list is not valid, or if the pattern compilation fails (indicating the cause of the failure).

Examples

pcreMatchList( "^[a-z][0-9]*" '(a01 x02 "003" aa01 "abc") )
=> (a01 x02 aa01 "abc")
pcreMatchList( "^[a-z][0-9][0-9]*" '(a001 b002 "003" aa01 "abc") )
=> (a001 b002)
pcreMatchList( "box[0-9]*" '(square circle "cell9" "123") )
=> nil
pcreMatchList("^[a-z][0-9][0-9]*" '("12\na001" b002) 
pcreGenCompileOptBits(?multiLine t) pcreGenExecOptBits( ?notbol t) )
=> ("12\na001")
pcreMatchList("^[a-z][0-9]*" '(abc 123)) 
=>
*Error* pcreMatchList: element in the list given as argument #2 must be either a symbol or a string - 123
pcreMatchList( "^[a-z][0-9]*$" '((abc "ascii") (a123 "alphanum")) ) 
=>
*Error* pcreMatchList: element in the list given as argument #2 must be either a symbol or a string - (abc "ascii")

Related Topics

String Functions

pcreCompile

pcreExecute

pcreGenCompileOptBits

pcreGenExecOptBits


Return to top
 ⠀
X