Please enable JavaScript to view this site.

 

str = getRegexResultString(sListResults, nMatchIndex, nGroupIndex)

 

This macro function is used after a call to the function StrFindRegex to obtain the strings corresponding to various matches obtained from that function.

 

•nMatchIndex identifies the match to retrieve, starting at 1. The number of matches is returned by the preceding call to StrFindRegex.

•nGroupIndex identifies the capture group within that match. Use 0 to retrieve the entire match, or 1 and above to retrieve a numbered capture group.

 

Requesting a match or group that is not present in the results list causes an error.

// create the list used to hold the regex results
sListRegexResults = List_Create('sListRegexResults')
// look for concatenated string of the form 09*†^§ø-18*†^§ø
sRegex = '([0-9]{2})([*†^§ø]{0,5})-([0-9]{2})([*†^§ø]{0,5})'
nNumRegexFound = StrFindRegex(sCurString, sRegex, sListRegexResults, true)
if nNumRegexFound == 1 // if current entry is a concatenated string
    sConcatMin = getRegexResultString(sListRegexResults, 1, 1)
    sSymbolsMin = getRegexResultString(sListRegexResults, 1, 2)
    sConcatMax = getRegexResultString(sListRegexResults, 1, 3)
    sSymbolsMax = getRegexResultString(sListRegexResults, 1, 4)
   // process these found values
   // ...
endif
// once we are done with the results list, dispose of it
List_Destroy(sListRegexResults)

See also: StrFindRegex, StrReplaceRegex, getRegexResultPosition.

 


Topic 188590, last updated on 09-Oct-2026