Replacing multiple spaces into just one?

bloodless2010

Okay, so I am working on this VB.NET program and I have tried using the .replace() to do this but it's not the best way to do this. I have a string with multiple spaces in between data which I don't want, what would be the best way to strip the spaces from the string but 1?

Guffa

Use a regular expression to match multiple spaces and replace with a single space:

s = Regex.Replace(s, " {2,}", " ")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

replacing spaces with just one "_"

From Dev

Replacing white spaces in prolog

From Dev

Replace non alphanumeric characters and multiple spaces with just 1 space

From Dev

Replacing multiple links in a string in one line of code in python

From Dev

Multiple replacement with just one regex

From Dev

XSLT replacing one elements with multiple elements

From Dev

Multiple await operations or just one

From Dev

Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

From Dev

Replacing multiple accented letters in string with one letter using list comprehension

From Dev

replacing the one child node value which is occurred multiple places with in the xml

From Dev

Replacing multiple characters in a string in c# by a one liner

From Dev

Multiple servlets, or just one main controller

From Dev

How to strip multiple spaces to one using sed?

From Dev

replacing spaces with just one "_"

From Dev

Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

From Dev

Replacing multiple special characters from a file with a perl one-liner

From Dev

Replacing multiple fragmentclass using one fragment view

From Dev

Replacing newlines with spaces in Vim

From Dev

Replace multiple spaces with one using 'tr' only

From Dev

"while read -r LINE; do" is replacing multiple spaces with a single space

From Dev

Replacing alternate spaces with newline?

From Dev

Bash - replace spaces with underscore but replace multiple spaces with one

From Dev

Multiple inputs with just one Setter

From Dev

mysql/php loop with multiple forms or just one?

From Dev

replacing spaces with chars

From Dev

How to truncate any spaces to just one space?

From Dev

Regex to merge multiple numbers with spaces in one line

From Dev

removing leading spaces and replacing multiple spaces

From Dev

Multiple publishers in a session, how subscribe to just one?

Related Related

  1. 1

    replacing spaces with just one "_"

  2. 2

    Replacing white spaces in prolog

  3. 3

    Replace non alphanumeric characters and multiple spaces with just 1 space

  4. 4

    Replacing multiple links in a string in one line of code in python

  5. 5

    Multiple replacement with just one regex

  6. 6

    XSLT replacing one elements with multiple elements

  7. 7

    Multiple await operations or just one

  8. 8

    Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

  9. 9

    Replacing multiple accented letters in string with one letter using list comprehension

  10. 10

    replacing the one child node value which is occurred multiple places with in the xml

  11. 11

    Replacing multiple characters in a string in c# by a one liner

  12. 12

    Multiple servlets, or just one main controller

  13. 13

    How to strip multiple spaces to one using sed?

  14. 14

    replacing spaces with just one "_"

  15. 15

    Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

  16. 16

    Replacing multiple special characters from a file with a perl one-liner

  17. 17

    Replacing multiple fragmentclass using one fragment view

  18. 18

    Replacing newlines with spaces in Vim

  19. 19

    Replace multiple spaces with one using 'tr' only

  20. 20

    "while read -r LINE; do" is replacing multiple spaces with a single space

  21. 21

    Replacing alternate spaces with newline?

  22. 22

    Bash - replace spaces with underscore but replace multiple spaces with one

  23. 23

    Multiple inputs with just one Setter

  24. 24

    mysql/php loop with multiple forms or just one?

  25. 25

    replacing spaces with chars

  26. 26

    How to truncate any spaces to just one space?

  27. 27

    Regex to merge multiple numbers with spaces in one line

  28. 28

    removing leading spaces and replacing multiple spaces

  29. 29

    Multiple publishers in a session, how subscribe to just one?

HotTag

Archive