2016-12-29 56 views
-4

我想從文本「使用703125 ABC:QWER => null - aaaaa.com選擇一個新列」aaaaa.com「。[VBN Res ID = 745075267#1(1/2)]房間1評論:此房價中不包含餐費。「這在SSRS的1列中出現。SSRS - 從段落中選擇1個詞

+1

你有什麼已經嘗試過?什麼地方出了錯?您對當前和期望行爲/輸出的清晰描述在哪裏?這個問題需要一些工作來反正,請看看[「我怎麼問一個好問題?」](http://stackoverflow.com/help/how-to-ask)並編輯你的相應的問題。 – 3N1GM4

回答

0

它可能更容易輸出爲2列在數據集中...但如果你不能那麼第二個選項將是使用VB代碼。

右鍵單擊代碼後面的空白處,然後單擊「Report Properties」。

然後在代碼部分粘貼此:

Function SplitText(text As String, column As Int16) As String 

     If (column = 1) Then 
      Return text.Substring(0, text.Substring(0, text.IndexOf(".com") + 4).LastIndexOf(" ")) 
     Else 
      Return text.Substring(text.Substring(0, text.IndexOf(".com") + 4).LastIndexOf(" ") + 1) 
     End If 
End Function 

然後在您的報告中使用這個表達式爲第一列:

=Code.SplitText(Fields!text.Value,1) 

,這第二

=Code.SplitText(Fields!text.Value,2) 

你有你的結果!

enter image description here

編輯 或者,如果你只是想在它自己使用的電子郵件地址驗證碼:

Function GetEmail(text As String) As String 

     Dim Result As String 
     Result = text.Substring(text.Substring(0, text.IndexOf(".co") + 3).LastIndexOf(" ") + 1) 
     Result = Result.Substring(0, Result.IndexOf(" ")) 

     Return Result 

    End Function