title: What is the regular expression to replace white space with a specified character?
body: <p>I have searched lot of questions and answers but, I just got lengthy and complicated expressions. Now I want to replace all white spaces from the string. I know it can be done by regex. but, I don't have enough knowledge about regex and how to replace all white space with ','(comma) using it. I have checked some links but, I didn't get exact answer. If you have any link of posted  question or answer like this. please suggest me. </p>
  
  <p>My string is defined as below.</p>
  
  <pre><code>string sText = "BankMaster      AccountNo              decimal      To   varchar";
  </code></pre>
  
  <p>and the result should be return as below.</p>
  
  <pre><code>"BankMaster,AccountNo,decimal,To,varchar"
  </code></pre>
  
  <p><strong>Full Code:</strong></p>
  
  <pre><code>string sItems = Clipboard.GetText();
  string[] lines = sItems.Split('\n');
  for (int iLine =0; iLine&lt;lines.Length;iLine++)
  {
      string sLine = lines[iLine];
      sLine = //CODE TO REPLACE WHITE SPACE WITH ','
      string[] cells = sLine.Split(',');
  
      grdGrid.Rows.Add(iLine, cells[0], cells[1], cells[2], cells[4]);
  }
  </code></pre>
  
  <p><strong>Additional Details</strong> </p>
  
  <p>I have more than 16000 line in a list. and all lines are same formatted like given example above. So, I am going to use regular expression instead of loop and recursive function call. If you have any other way to make this process more faster than regex then please suggest me.</p>