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

pcreExecute

pcreExecute( 
o_comPatObj 
S_subject 
[ x_options ] 
) 
=> t / nil

Description

Matches the subject string or symbol (S_subject) against a previously compiled pattern set up by the last pcreCompile call (o_comPatObj). The matching algorithm is PCRE/Perl-compatible. You can use a third (optional) argument to specify independent option bits for controlling pattern matching. You can use this function in conjunction with pcreCompile to match several subject strings or symbols against a single pattern.

Arguments

o_comPatObj

Data object containing the compiled pattern returned from a previous pcreCompile call.

S_subject

Subject string or symbol to be matched. If it is a symbol, its print name is used.

x_options

(Optional) Independent option bits that affect pattern matching. You can specify zero or more of these options symbolically using the pcreGenExecOptBits SKILL function.

Valid Values:

PCRE_ANCHORED

Equivalent to setting ?anchored t using the pcreGenExecOptBits SKILL function.

PCRE_NOTBOL

Equivalent to setting ?notbol t using the pcreGenExecOptBits SKILL function.

PCRE_NOTEOL

Equivalent to setting ?noteol t using the pcreGenExecOptBits SKILL function.

PCRE_NOTEMPTY

Equivalent to setting ?notempty t using the pcreGenExecOptBits SKILL function.

PCRE_PARTIAL

Equivalent to setting ?partial t using the pcreGenExecOptBits SKILL function.

Value Returned

t

A match is found.

nil

No match. You can see the error message associated with this matching failure by calling pcrePrintLastMatchErr.

Examples

comPat1 = pcreCompile( "[12[:^digit:]]" ) 
=> pcreobj@0x27d150
pcreExecute( comPat1 "abc" )             
=> t 
comPat2 = pcreCompile( "((?i)ab)c" ) 
=> pcreobj@0x27d15c
pcreExecute( comPat2 "aBc" )  
=> t
comPat3 = pcreCompile( "\\d{3}" ) 
=> pcreobj@0x27d168
pcreExecute( comPat3 "789" )  
=> t 
comPat4 = pcreCompile( "(\\D+|<\\d+>)*[!?]" ) 
=> pcreobj@0x27d174
pcreExecute( comPat4 "Hello World!" )  
=> t
comPat5 = pcreCompile( "^\\d?\\d(jan|feb|mar|apr|may|jun)\\d\\d$/" ) 
=> pcreobj@0x27d180
pcreExecute( comPat5 "25jun3" ) => nil
pcreExecute( comPat5 "25jun3" pcreGenExecOptBits(?anchored t) )
=> nil
pcreExecute( comPat5 "25jun3" pcreGenExecOptBits(?partial t) )
=> t 

Related Topics

String Functions

pcreCompile

pcreExecute

pcreGenExecOptBits


Return to top
 ⠀
X