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



My Own Work
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("Hello-World-Cruel", "", "-", 1) = "Hello"
CutString("Hello-World-Cruel", "-","-", 1) = "World"

Views 5853 Downloads 1388

Classic ASP Texts + Strings