Method RegEx():precompile() Foundation

Forces immediate pattern compilation.

Syntax
:precompile() --> lSuccess
Return

.T. (true) if compilation is successful, .F. (false) on error.

Description

Compiles the pattern assigned to the RegEx object immediately instead of waiting for the first use. This can be useful to validate patterns early or to move the compilation cost outside of performance-critical sections.

After compilation, the method :optimize() can be used to improve the speed of pattern execution.

Precompile

oRegEx := RegEx():create("^[A-Z]+$") 

IF !oRegEx:precompile() 
? "Invalid pattern: " + oRegEx:getLastMessage() 
ENDIF 

// Use oRegEx 

oRegEx:destroy() 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.