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.
Arguments
|
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:
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
|
Equivalent to setting |
|
Value Returned
|
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
Return to top