Remove chars from string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ventsislav
    New Member
    • Mar 2009
    • 16

    Remove chars from string

    Hi! I have str = "abv, ". How can I remove the comma and th space at the end faster?
  • kunal pawar
    Contributor
    • Oct 2007
    • 297

    #2
    This function used to remove char from string Or you can use Trim function.
    string boject.Replace( old char,new char);

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      Regular Expression are good alternative to String.Replace for large strings...

      Comment

      • ventsislav
        New Member
        • Mar 2009
        • 16

        #4
        I did it like this: str = str.Remove(str. Length - 2, 2);

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Originally posted by ventsislav
          I did it like this: str = str.Remove(str. Length - 2, 2);
          Are you sure there will always only be 2 characters at the end that you don't want?

          Comment

          • ventsislav
            New Member
            • Mar 2009
            • 16

            #6
            Yes, I know exactly what' s the string like, and that the last 2 chars are needless. But yet thanks!

            Comment

            Working...