Reputation: 2077
i wish to modify a string. In ssis I have a step which is a "Derived column transformation editior". I have a string such as:
edit=style?form=exy?test=x~~StringIWantToRemove
I wish to remove "~~StringIWantToRemove" "~~" is the delimiter "StringIWantToRemove" is a random string og any value (apart from the delimiter)
I would try find index of ~~ then len of string then remove from that point but not sure how to do it in ssis.
help?
Upvotes: 0
Views: 1208
Reputation: 2077
in the end I used a script component:
Dim debugOn As Boolean
debugOn = False
If debugOn Then MsgBox(Row.trackingCode)
If Row.trackingCode <> "" Then
' find the delimiter location
Dim endLocation As Integer
If debugOn Then MsgBox("index of ~~ is " & Row.trackingCode.ToString().IndexOf("~~", 0))
' chk if we have ~~ in field, if not in field then -1 is returned
If Row.trackingCode.ToString().IndexOf("~~", 0) > -1 Then
' if ~~ at the beginning ie no tracking code
If Row.trackingCode.ToString().IndexOf("~~", 0) = 1 Then
endLocation = Row.trackingCode.ToString().IndexOf("~~", 0)
ElseIf Row.trackingCode.ToString().IndexOf("~~", 0) > 1 Then
endLocation = Row.trackingCode.ToString().IndexOf("~~", 0) - 1
End If
If debugOn Then MsgBox("end of track code is " & endLocation)
Row.trackingCode = Row.trackingCode.Substring(1, endLocation)
End If
End If
Upvotes: 0
Reputation: 89661
I would consider using a script task with a regex - it's probably easier than trying to distill it down into a one-liner in a derived column task.
Upvotes: 1