'********************************************************************
'*
'* Function strBetween
'*
'* Author: NetworkAdminKB.com
'* Created: 2005-11-04
'* Modified: 2008-12-06
'*
'* Purpose: Returns the string between the matching characters.
'* The "between" is measured from both ends towards the
'* middle of the string.
'*
'* Input: strSearch = A string to be searched.
'* strMatch = A string/Character to search for in strSearch.
'* blnCase = A boolean indicating case sensitive searches
'* True = Case Sensitive Search
'* False = Case Insensitive Search
'*
'* Output: Returns the string between the mating characters.
'* Returns Empty if there is no match.
'*
'* Calls:
'* blnInStr
'* ReturnCaseComparisonValue
'*
'* Changes:
'* 2008-12-06: Added blnCase, intSearch and ReturnCaseComparisonValue
'* to support case sensitive and insensitive searches.
'********************************************************************
Function strBetween(ByVal strSearch, ByVal strMatch, ByVal blnCase)
'Version 1.1 2008-12-06
Dim intStartPos, intEndPos, intLen, intLMatch, intSearch
intLMatch = Len(strMatch)
intSearch = ReturnCaseComparisonValue(blnCase)
If blnInStr(strSearch, strMatch, blnCase) Then
intStartPos = InStr(1, strSearch, strMatch, intSearch)
intEndPos = InStrRev(strSearch, strMatch, -1, intSearch)
If intLMatch > 1 Then
intEndPos = intEndPos - intLMatch
End If 'intLMatch > 1
If intStartPos < intEndPos Then
intLen = intEndPos - intStartpos - 1
If intLMatch > 1 Then
intLen = intLen + 1
End If 'intLMatch > 1
strBetween = Mid(strSearch, intStartPos + intLMatch, intLen)
Else
strBetween = Empty
End If 'intStartPos < intEndPos Then
Else
strBetween = Empty
End If 'blnInstr(strSearch, strMatch)
End Function 'strBetween
Article ID: 422, Created On: 9/25/2011, Modified: 9/25/2011