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

pcreCompile

pcreCompile( 
t_pattern 
[ x_options ] 
) 
=> o_comPatObj / nil

Description

Compiles a regular expression string pattern (t_pattern) into an internal representation that you can use in a pcreExecute function call. The compilation method is PCRE/Perl-compatible. You can use a second (optional) argument to specify independent option bits for controlling pattern compilation. 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.

PCRE stands for Perl Compatible Regular Expressions. The PCRE library contains functions that implement Perl-compatible regular expression pattern matching. You can visit http://www.pcre.org for more information.

Arguments

t_pattern

String containing regular expression string to be compiled.

x_options

Optional) Independent option bits that affect the compilation. You can specify zero or more of these options symbolically using the pcreGenCompileOptBits SKILL function.

Valid Values:

PCRE_CASELESS / 0x00000001

Equivalent to setting ?caseLess t using the pcreGenCompileOptBits SKILL function.

PCRE_MULTILINE / 0x00000002

Equivalent to setting ?multiLine t using the pcreGenCompileOptBits SKILL function.

PCRE_DOTALL / 0x00000004

Equivalent to setting ?dotAll t using the pcreGenCompileOptBits SKILL function.

PCRE_EXTENDED / 0x00000008

Equivalent to setting ?extended t using the pcreGenCompileOptBits SKILL function.

PCRE_ANCHORED / 0x00000010

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

PCRE_DOLLAR_ENDONLY / 0x00000020

Equivalent to setting ?dollar_endonly t using the pcreGenCompileOptBits SKILL function.

PCRE_UNGREEDY / 0x00000200

Equivalent to setting ?ungreedy t using the pcreGenCompileOptBits SKILL function.

PCRE_NO_AUTO_CAPTURE / 0x00001000

Equivalent to setting
?no_auto_capture t using the pcreGenCompileOptBits SKILL function.

PCRE_FIRSTLINE / 0x00040000

Equivalent to setting ?firstline t using the pcreGenCompileOptBits SKILL function.

Value Returned

o_comPatObj

Data object containing the compiled pattern.

nil

Pattern compilation failed. An error message indicating the cause of the failure appears.

Examples

comPat1 = pcreCompile( "\\Qabc\\$xyz\\E" ) 
=> pcreobj@0x27d0fc
pcreExecute( comPat1 "abc\\$xyz" )  
=> t
comPat2 = pcreCompile( "sam|Bill|jack|alan|bob" ) 
=> pcreobj@0x27d108
pcreExecute( comPat2 "alan" )          
=> t
comPat3 = pcreCompile( "z{1,5}" ) 
=> pcreobj@0x27d120
pcreExecute( comPat3 "zzzzz" )
=> t
comPat4 = pcreCompile( "/\\*.*?\\*/" ) 
=> pcreobj@0x27d12c
pcreExecute( comPat4 "/* first command */ not comment /* second comment */" )
=> t
comPat5 = pcreCompile( "^[a-z][0-9a-z]*" pcreGenCompileOptBits(?caseLess t) ) 
=> pcreobj@0x27d138
pcreExecute( "AB12cd" )
=> t
comPat6 = pcreCompile( "[a-z" ) 
=> *Error* pcreCompile: compilation failed at offset 4: missing terminating ] for character class
nil

Related Topics

String Functions

pcreExecute

pcreGenCompileOptBits


Return to top
 ⠀
X