Method RegEx():setUngreedy() Foundation

Sets ungreedy (lazy) quantifier mode.

Syntax
:setUngreedy( [<lUngreedy>] ) --> self
Parameters
<lUngreedy>
Set to .T. (true) to enable ungreedy mode. A value of .F. (false) disables the feature. Defaults to .T.
Return

This method returns self.

Description

In ungreedy mode, quantifiers like * and + become lazy by default, matching as few characters as possible. Normal greedy behavior can be restored for individual quantifiers by following them with ?.

Set ungreedy mode

oRegEx := RegEx():create("<.*>"):setUngreedy() 
aMatch := oRegEx:match("<b>text</b>") 
? RegEx():getMatchText(aMatch)  // "<b>" (not "<b>text</b>") 
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.