How to Replace Multiple space with only one space

Use regular expression

RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@”[ ]{2,}”, options);
tempo = regex.Replace(tempo, @” “);

VB.Net

Dim str As String = “Sample space 01″
Dim opts As RegexOptions = RegexOptions.None
Dim regx As New Regex(“[ ]{2,}”, opts)

str = regx.Replace(str, ” “)

,

  1. No comments yet.
(will not be published)
Submit Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Subscribe to comments feed
  1. No trackbacks yet.

SetPageWidth