2009-01-16 31 views
0

我想修改一个字符串。在ssis中,我有一个“派生列转换编辑器”的步骤。我有一个字符串,例如:如何删除SSIS中设置的字符串模式?

edit=style?form=exy?test=x~~StringIWantToRemove 

我希望删除“~~ StringIWantToRemove” “*”是分隔符 “StringIWantToRemove”是一个随机字符串OG(除了分隔符)的任何值

我会试着找到~~的索引,然后len的字符串,然后从这一点删除,但不知道如何在ssis中做到这一点。

帮助?

回答

0

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 
1

我会考虑使用带有正则表达式的脚本任务 - 这可能比试图将其提取到派生列任务中的单线程更容易。

在我使用的脚本组件端
+0

我试图做 SUBSTRING(trackingCode,1,FINDSTRING(trackingCode, “*”,1) - 1) 所述的问题上面是“-1” – thiswayup 2009-01-20 09:58:19

相关问题