Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>"Spaces" in the original post could refer to whitespace, and no answer yet shows how to remove ALL <strong>whitespace</strong> from a string. For that regular expressions are the most flexible approach I've found.</p> <p>Below is a console application where you can see the difference between replacing just spaces or all whitespace.</p> <p>You can find more about .NET regular expressions at <a href="http://msdn.microsoft.com/en-us/library/hs600312.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/hs600312.aspx</a> and <a href="http://msdn.microsoft.com/en-us/library/az24scfc.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/az24scfc.aspx</a></p> <pre><code>Imports System.Text.RegularExpressions Module TestRegExp Sub Main() ' Use to match all whitespace (note the lowercase s matters) Dim regWhitespace As New Regex("\s") ' Use to match space characters only Dim regSpace As New Regex(" ") Dim testString As String = "First Line" + vbCrLf + _ "Second line followed by 2 tabs" + vbTab + vbTab + _ "End of tabs" Console.WriteLine("Test string :") Console.WriteLine(testString) Console.WriteLine("Replace all whitespace :") ' This prints the string on one line with no spacing at all Console.WriteLine(regWhitespace.Replace(testString, String.Empty)) Console.WriteLine("Replace all spaces :") ' This removes spaces, but retains the tabs and new lines Console.WriteLine(regSpace.Replace(testString, String.Empty)) Console.WriteLine("Press any key to finish") Console.ReadKey() End Sub End Module </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload