Linked Questions

-2 votes
3 answers
2k views

Which is the most performance efficient way to remove multiple characters from a C# string? I have to remove all the spaces, hyphen from a C# string. Thanks
Vishnu Y's user avatar
  • 2,341
1 vote
1 answer
831 views

I have created a function to 'filter' a string by removing various characters using the .Replace method, I am also removing anything at the end of the string that starts with '(' using the Substring ...
Zack Antony Bucci's user avatar
798 votes
13 answers
558k views

How do I remove all non alphanumeric characters from a string except dash and space characters?
Luke101's user avatar
  • 65.7k
48 votes
10 answers
298k views

I have the following code string line = ""; while ((line = stringReader.ReadLine()) != null) { // split the lines for (int c = 0; c < line.Length; c++) { if ( line[c] == ',' &...
I am not smart's user avatar
34 votes
6 answers
45k views

I have some strings like this string phoneNumber = "(914) 395-1430"; I would like to strip out the parethenses and the dash, in other word just keep the numeric values. So the output could look like ...
meda's user avatar
  • 45.5k
28 votes
13 answers
81k views

I'm trying to fetch multiple email addresses seperated by "," within string from database table, but it's also returning me whitespaces, and I want to remove the whitespace quickly. The following ...
Joe's user avatar
  • 399
16 votes
7 answers
42k views

I want to remove all special characters from a string. Allowed characters are A-Z (uppercase or lowercase), numbers (0-9), underscore (_), white space ( ), pecentage(%) or the dot sign (.). I have ...
OBL's user avatar
  • 1,357
15 votes
9 answers
92k views

I am trying to find if there is better way to check if the string has special characters. In my case, anything other than alphanumeric and a '_' is considered a special character. Currently, I have a ...
Praveen's user avatar
  • 1,861
8 votes
3 answers
6k views

I need to do an update but the column name is dynamic. Code Snippet: using (var cn = Connection) { var sql = @"UPDATE Teste SET @columnName = @parameter, DT_PROCESSAMENTO = @...
Nathália Neves's user avatar
0 votes
6 answers
5k views

I'm trying to get all characters in a string that occur before a certain character. For example: string id = "Hello everyone! Good day today."; id = id.Remove(id.IndexOf('!')); Console....
sha1's user avatar
  • 39
3 votes
3 answers
280 views

I have a function that fixed non-printable characters in C# for JavaScript. But it works very slow! How to increase speed of this function? private static string JsStringFixNonPrintable(string Source)...
Vadim's user avatar
  • 31
-2 votes
3 answers
753 views

String reverse which contains spaces and special characters. How can I achieve this without using regex? Input: "M @#.AD()/A?#M" Output :"MADAM"
Vihar Jadhav's user avatar
0 votes
1 answer
1k views

I'm new to C#. In a project, I'm dealing with serial communication where I'm trying to send/receive a checksum for verifying data transfer integrity. The device I'm sending messages to accepts ascii ...
user2188329's user avatar
-2 votes
2 answers
837 views

I have a list of strings which has got some characters in it. On viewing it in HTML viewer I get the following I tried line.Replace() to remove some special characters but it doesn't work.
Newton Sheikh's user avatar
2 votes
2 answers
527 views

So I'm trying to make a simple login system in Unity using C#, PHP and MySQL on localhost, but there is a problem. My code works like this: In the php file, if the username and password matches the ...
Ênio José's user avatar

15 30 50 per page