Cuts a string from certain char till certain char, can be used to cut left, right and mid section of a string.

Function CutString(FromString, CutFrom, ToString, StartFromChar)
 ' Cuts a string from a string starting from a specific charactor and until a specific charactor
 ' FromString is the char to cut from (not included)
 ' Case-sensetive
 ' ToString is the char to stop cut to (after FromString is found) (not included)
 ' CurFrom is the string to cut from
 ' StartFromChar is the number of charactor to start search from
 ' If CutFrom is not given or not found, it will be assumed as 1
 ' If ToString is not given or not found, it will be assumed as the length of the string
 CutString    = ""
 StartFromChar   = 1
If CutFrom > "" Then
  If InStr(StartFromChar, FromString, CutFrom) > 0 Then
   StartFromChar = InStr(StartFromChar, FromString, CutFrom) + Len(CutFrom)
  End If
End If
CutString    = Mid(FromString, StartFromChar)
If ToString > "" Then
End1    = Len(FromString)
If InStr(StartFromChar, FromString, ToString) > 0 Then
End1   = InStr(StartFromChar, FromString, ToString) - StartFromChar
End If
CutString   = Mid(FromString, StartFromChar, End1)
End If
End Function

FromString, CutFrom, ToString, StartFromChar

CutString(&#34;Hello-World-Cruel&#34;, &#34;&#34;, &#34;-&#34;, 1) = &#34;Hello&#34;<br/>CutString(&#34;Hello-World-Cruel&#34;, &#34;-&#34;,&#34;-&#34;, 1) = &#34;World&#34;

Views 3198 Downloads 795

'StringArray', 'StrANArray', 'ANStr', 'ANString', 'ANStrList'

Texts + Strings Classic ASP