Results 1 to 7 of 7
  1. #1
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

    Default Converting all spaces to Single Space

    I have a string like this:

    "Text TExt more Text"

    How can I convert that too

    "Text TExt more Text"

    Any ideas?

    Thanks

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    what?...9A
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  3. #3
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    oh ic, this forum stripped out the spaces.
    s.replaceAll("\\s+"," ");
    Last edited by angryboy; 02-25-2009 at 02:53 AM.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  4. #4
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    html doesn't render multiple spaces =p

    edit: ok that just sounded wrong. browsers do the rendering, but yeah... normally won't render consecutive spaces... i'll shut up now
    Last edited by emceenugget; 02-25-2009 at 02:58 AM. Reason: i sounded stupid

  5. #5
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

    Default

    oh lol, I need to do what this Forum does!

    s.replaceAll("\\s+"," ");

    Worked perfectly, thank you.

  6. #6
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

    Default

    ok, that worked for spaces at the middle and end of the string but it doesn't remove spaces at the beginning of the string, how would I remove all the spaces at the beginning of a string?

  7. #7
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

Similar Threads

  1. How do i add spaces ~(very simple)
    By soc86 in forum New To Java
    Replies: 3
    Last Post: 11-02-2008, 03:01 AM
  2. Caesar and encoding with block spaces
    By Franneldort in forum New To Java
    Replies: 13
    Last Post: 10-30-2008, 05:48 PM
  3. Load URL that contains spaces?
    By barkster in forum Java Applets
    Replies: 0
    Last Post: 01-30-2008, 10:40 PM
  4. Replies: 0
    Last Post: 01-08-2008, 06:29 PM
  5. Help with a word, if it is divided by spaces
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •