' ========================================================================================
PRIVATE FUNCTION wstrExtract (BYREF wszSourceString AS CONST WSTRING, BYREF wszMatchString AS CONST WSTRING, BYVAL IgnoreCase AS BOOLEAN = TRUE) AS DWSTRING
IF wszSourceString = "" OR wszMatchString ="" THEN RETURN wszSourceString
DIM pRegExp AS CRegExp
pRegExp.Global = FALSE
pRegExp.IgnoreCase = IgnoreCase
' // This pattern matches the delimiter passed (can consist of a group of one or more characters)
' // Passing wszMatchString enclosed between "[]" will match any of the individual characters
pRegExp.Pattern = "^(.*?)" & wszMatchString
SetLastError(pRegExp.Execute(wszSourceString))
iF pRegExp.SubMatchesCount THEN
RETURN STRPTR(pRegExp.SubMatchValue(0, 0))
END IF
' // If wszMatchString is not found return all of wszSourceString
RETURN wszSourceString
END FUNCTION
' ========================================================================================
DIM dws AS DWSTRING = "abacadabra"
Print wstrExtract(dws, "cad")
' Output: aba - match on "cad"
DIM dws AS DWSTRING = "abacadabra"
Print wstrExtract(dws, "[dr]")
' Output: abaca - match on "d"
print g_S(1) space(30-len(g_S(1))) " >> " g_S(2) cr
type TCITEM int mask,dwState,dwStateMask, char* pszText, int cchTextMax,iImage, sys lParam
typedef TCITEM TC_ITEM
type TBADDBITMAP , sys hInst , sys nID
type TBBUTTON , int iBitmap , int idCommand , BYTE fsState , BYTE fsStyle , dword dwData , sys iString
Page created in 0.098 seconds with 11 queries.