2 Replies - 143 Views - Last Post: 08 February 2012 - 03:27 AM Rate Topic: -----

Topic Sponsor:

#1 CreaturGames  Icon User is offline

  • D.I.C Regular

Reputation: 26
  • View blog
  • Posts: 254
  • Joined: 29-December 09

Replacing Non-Spaces with Spaces within a string

Posted 08 February 2012 - 02:36 AM

How would I do so?

I have tried:

string code = text.Replace("", " ");


But that came only with an exception.

Help please.
Is This A Good Question/Topic? 0
  • +

Replies To: Replacing Non-Spaces with Spaces within a string

#2 janne_panne  Icon User is offline

  • le Tit
  • member icon

Reputation: 379
  • View blog
  • Posts: 993
  • Joined: 09-June 09

Re: Replacing Non-Spaces with Spaces within a string

Posted 08 February 2012 - 03:26 AM

What are non spaces? Do you want a space between each character? Like "hello" -> "h e l l o"?

Or do you mean characters that can't be seen but they still are there as non spaces, like you can't see carriage return or line feed but they mark where the line changes?
Then you'd have to do this:
string code = text.Replace("\r\n", " ");
Was This Post Helpful? 0
  • +
  • -

#3 negligible  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 56
  • View blog
  • Posts: 272
  • Joined: 02-December 10

Re: Replacing Non-Spaces with Spaces within a string

Posted 08 February 2012 - 03:27 AM

"" is empty.
" " is a space.

So that would never work. Try specifying each character you want to replace.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1