Please enable JavaScript to view this site.

 

int = StrFindRegex(sFull,sFind,sListResults,bIgnoreCase)

 

This macro function takes a string sFull and searches for occurrences of the string sFind using regular expressions.

 

The result of this function is the number of occurrences of sFind that are found using regex.

 

The details of the found text, if any, are contained in the list sListResults.

 

To obtain the strings corresponding to various matches obtained from the present function, see the function getRegexResultString and to obtain the positions corresponding to various matches obtained from the present function, see the function getRegexResultPosition.

If you only need to know if there is a match (ie. the result of the function is 1 or more), then you can leave the value of sListResults as blank.

However, if you need the details of the regex match(es), then you need to use List_Create and List_Destroy to create and dispose of the list sListResults.

 

Below is an example of the use of the macro function StrFindRegex.

// 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, 11)
    sSymbolsMin = getRegexResultString(sListRegexResults, 12)
    sConcatMax = getRegexResultString(sListRegexResults, 13)
    sSymbolsMax = getRegexResultString(sListRegexResults, 14)
   // process these found values
   // ...
endif
// once we are done with the results list, dispose of it
List_Destroy(sListRegexResults)

See also: Pos, PosNth, StrIsContained, StrReplaceRegex.

 


Topic 188585, last updated on 23-Jun-2025