CodeItBetter Programming Another VB Programming Blog

How to replace only the LAST occurrence of a substring.

Posted on January 4, 2009
1
2
3
4
5
'String Manipulation - How to replace only the LAST occurrence of a substring.
Function ReplaceLast(Source As String, Search As String, ReplaceStr As String) As String
    ReplaceLast = StrReverse(Replace(StrReverse(Source), StrReverse(Search), _
        StrReverse(ReplaceStr), , 1))
End Function

Related posts:

  1. How to count the number of occurrences of a substring inside another string
  2. How to check if a given string starts with a given substring
  3. How to check if a given string ends with a given substring
  4. How to find a string between two substring on a given string phrase
  5. How to Replace a string on first line of a text box.
  6. How to use Replace function for VB5
  7. How to replace a character in middle of the string
  8. How to Replace Multiple Substrings in a String at Once
  9. Replacement for VB6’s Replace$ function (fastest way)
  10. How to do Replace All in Visual Basic

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.