Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Substring starting at specific character count
  2. Dim testString As String = "part, description, order, get this text, and this text"
  3. Dim result As String = ""
  4. result = testString.Substring(testString.IndexOf(",", 0, 3))
  5.        
  6. string.Join(",", "aaa,bbb,ccc,ddd,eee".Split(',').Skip(2));
  7.        
  8. Dim testString As String = "part, description, order, get this text"
  9. Dim result As String = ""
  10. result = testString.Substring(testString.LastIndexOf(",") + 1)
  11.        
  12. ' You can add code to check if the LastIndexOf returns a positive number
  13. Dim result As String = testString.SubString(testString.LastIndexOf(",")+1)
  14.        
  15. Dim result As String = Regex.Replace(testString, "(.*,)(.*)$", "$2")
  16.        
  17. Dim testString As String = "part, description, order, get this text"
  18. Dim index As Int32 = 0
  19.  
  20. For i As Int32 = 1 To 3    
  21.   index = testString.IndexOf(","c, index + 1)
  22.   If index < 0 Then
  23.     ' Not enough commas. Handle this.
  24.   End If
  25. Next
  26. Dim result As String = testString.Substring(index + 1)
  27.        
  28. Dim testString As String = "part, description, order, get this text"
  29.     Dim resultArray As String() = testString.Split(New Char() {","c}, 3)
  30.     Dim resultString As String = resultArray(2)
  31.        
  32. Dim testString As String = "part, description, order, get this text"
  33.     Dim resultArray As String() = testString.Split(New Char() {","c}, 3)
  34.     Dim resultString As String = resultArray(2)