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

pcreMatchp

pcreMatchp( 
g_pattern 
S_subject 
[ x_compOptBits ] 
[ x_execOptBits ] 
) 
=> t / nil

Description

Checks to see whether the subject string or symbol (S_subject) matches the specified regular expression pattern (g_pattern). 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. For greater efficiency when matching a number of subjects against a single pattern, you should use pcreCompile and pcreExecute.

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, pcreMatchp skips pattern compilation and ignores x_compOptBits.

Arguments

g_pattern

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

S_subject

Subject string or symbol to be matched. 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

t

A match is found.

A message appears if you have any errors in the regular expression pattern.

nil

No match.

An error message indicating the cause of the matching failure appears.

Examples

pcreMatchp( "[0-9]*[.][0-9][0-9]*" "100.001" ) 
=> t
pcreMatchp( "[0-9]*[.][0-9]+" ".001" )      
=> t
pcreMatchp( "[0-9]*[.][0-9]+" "." )         
=> nil
pcreMatchp( "[0-9" "100" ) 
=>
*Error* pcreCompile: compilation failed at offset 4: missing terminating ] for character class nil
pcreMatchp( "((?i)rah)\\s+\\1" "rah rah" ) 
=> t
pcreMatchp( "^[0-9]+" "abc\n123\nefg" 
pcreGenCompileOptBits(?multiLine t) pcreGenExecOptBits( ?notbol t) )
=> t

Related Topics

String Functions

pcreCompile

pcreExecute

pcreGenCompileOptBits

pcreGenExecOptBits


Return to top
 ⠀
X