Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace occurrences of "-" with an empty string?

Tags:

string

c#

I have this string: "123-456-7"

I need to get this string: "1234567"

How I can replace occurrences of "-" with an empty string?

like image 280
Gold Avatar asked May 21 '09 20:05

Gold


People also ask

How do you replace a character in a string with empty character?

Replace(';',string. Empty. ToCharArray()[0]) or Replace(";", "") also works.

How do you replace text in an empty string in Python?

Using 'str.replace() , we can replace a specific character. If we want to remove that specific character, replace that character with an empty string. The str. replace() method will replace all occurrences of the specific character mentioned.

How do you replace a string with spaces?

replace() method to replace all spaces in a string, e.g. str. replace(/ /g, '+'); . The replace() method will return a new string with all spaces replaced by the provided replacement.


1 Answers

string r = "123-456-7"; r = r.Replace("-", ""); 
like image 134
Sean Bright Avatar answered Sep 28 '22 01:09

Sean Bright