RegExp.Ungreedy (gb.pcre)

Const Ungreedy As Integer = 262144 ' &H40000

Inverts the greediness of each quantifier. Every quantifier has a greedy and an ungreedy variant, e.g. the "+" quantifier is greedy and its ungreedy variant is "+?". Setting the Ungreedy flag converts all greedy variants to ungreedy ones and vice versa. It does not make all quantifiers ungreedy.

Example

Private Function Apply(Pattern As String, Subject As String, Optional CompileFlags As Integer) As String
  Dim rExp As New RegExp(Subject, Pattern, CompileFlags)

  Return rExp.Text
End

Public Sub Main()
  Print Apply("a.+b",  "aabaaaab")
  Print Apply("a.+b",  "aabaaaab", RegExp.Ungreedy) ' make "+" into "+?"
  Print Apply("a.+?b", "aabaaaab")
  Print Apply("a.+?b", "aabaaaab", RegExp.Ungreedy) ' make "+?" into "+"
End
aabaaaab
aab
aab
aabaaaab