Delete Additional while spaces in a String

Hi Friends,
How do we delete additional white spaces inbetween a String.
Eg:-
String a = "hello     everyone     out       therer";should be printed as
"hello everyone out there"What could be the optimized solution for this?
Thanks.

beejum wrote:
It works. Thanks a lot.Note that \s also matches new lines. So when you are doing this on text that has line characters, those new lines will also be replaced by a single white space.
Also, "\\s+" will match single spaces which then get replaced with a single white space, so you could do "\\s{2,}" which will match 2 or more white space characters, or "[ ]{2,}" if you don't want to replace new lines (and tabs).

Similar Messages

  • Getting rid of trailing space from a string variable

    I need to delete trailing blank spaces in a string variable. Is there a method that can do the job?
    Thanks

    String.trim(). Example: " booh! ".trim() returns "booh!".

  • Problem while deleting a name space

    Hi All,
    When i delete a name space, its says it cannot delete as the objects (ExchangeLogData,ExchangeFaultData) are referring some xyz interface which doesn't even exist under the SCW.
    Please help me out to solve the error.
    regards,
    younus

    Hi,
    The error is
    "Error while parsing or executing XML-SQL document: Error processing request in sax parser: No 'action' attribute found in XML document (attribute "action" missing or wrong XML structure)"
    My target structure has action attribute in it, and the message mapping is working fine.
    What could be the error,  Please help me.
    regards

  • How to delete excessive spaces for a string??

    like String s="i am a new guy"
    how to make it to "i am a new guy" ??
    i've tried trim() seems it does work for this case
    thanks

    oh......no i typed several spaces symbol between "i"
    and "am" in the first sentence, but this forum seems
    ignore those blank spacesIt doesn't if you use code tags. And it's not the forum, but HTML standard.
    so what i am trying to do is. what if there are say,
    100 spaces between two words in a sentence (string)
    and i want to delete the excessive space and make it
    just one space between two wordsThen trim() doesn't do what you want it to do. As the documentation clearly describes. Use replaceAll.

  • Delete white spaces between two strings

    hi!
    How do I remove white spaces between two strings. I have attached file for reference.
    Thanks
    Attachments:
    untitled4.JPG ‏62 KB

    You first need to define what you consider to be "whitespace". Is it just a space? Is it spaces and linefeeds? What about carriage returns? Tabs? Anything non-alphabetic and/or non-numeric?
    As mentioned previously, the Search and Replace String can be used to delete characters by wiring an empty string to the replace string input. The following, for example, will delete all spaces:
    If you need to delete other whitespace characters, just call it again on the resulting string.
    Message Edited by smercurio_fc on 06-02-2008 09:25 AM
    Attachments:
    Example_VI1.png ‏3 KB

  • My bluetooth will not turn on, I may have accidentally deleted something while using "clean master"? is there a way to recover or reload without doing a factory reset? Thanks.Android 4.2.2  Jelly bean

    thanks
    Locked - please see duplicate discussion:
    My bluetooth will not turn on, I may have accidentally deleted something while using "clean master"? is there a way to r…
    Message was edited by: Admin Moderator

        Sorry to hear that the Bluetooth data/profiles may have been deleted from your phone. Accidents happen!
    oznaw, to be honest, I believe you will need to perform a master reset in order to recover the missing Bluetooth data, as there is nothing really available in the Play Store that just updates the Bluetooth profiles/data. Let us know if you have any additional questions, or if you found an alternative. Thank you oznaw.
    NicandroN_VZW
    Follow us on twitter @VZWSupport

  • How do you create additional free space on the volume containing the iPhoto library?  I have plenty of HD space.

    How do you create additional free space on the volume containing the iPhoto library?  When attempting to import images from a CD I get an "Insufficient Disk Space" message albeit there is plaenty of additional space on the hard drive.

    How much free space do you have on your hard drive?  Try the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
    User/Home/Library/Caches/com.apple.iPhoto folder (Snow Leopard and Earlier).
    or with Mt. Lion from the User/Library/Containers/com.apple.iPhoto/
    Data/Library/Caches/com.apple.iPhoto folder
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    NOTE 2:  In Lion and Mountain Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.

  • How do I remove extra white spaces in a string?

    How do I remove extra white spaces in a string?
    trim() removes before and after spaces.
    If I have a string "This is Test"
    I want to remove extra spaces between words and also I want to keep SINGLE space
    between words. So output should be "This is Test". Thanks.

    replaceAll dosen't support with my version. Actually this works..............!!!!!!!!! Thank you.
                        java.util.StringTokenizer st = new java.util.StringTokenizer(brn, " \t");
                        StringBuffer buf = new StringBuffer();
                        while (st.hasMoreTokens()) {
                             buf.append(" ").append(st.nextToken());
                        String brn1 = buf.toString().trim();

  • TS4009 before upgrading to Lion, I switched from MobileMe to iCloud.  At that time I used my MobileMe user name and password.  I purchased additional storage space to 20GB.  I was unabl to send any emails during this time.  After researching, I upgraded t

    before upgrading to Lion, I switched from MobileMe to iCloud.  At that time I used my MobileMe user name and password.  I purchased additional storage space to 20GB.  I was unable to send any emails during this time.  After researching, I upgraded to Lion and changed my icloud mail usuer name and password from the original I used from mobileme.  How do I get my upgraded storage to my new account.  I intend to delete the first one.
    Please help!

    Welcome to the Apple Community.
    Unfortunately you can't, the additional storage belongs to your first account, you can't transfer it.

  • Restore iPod - Why no additional free space (actually less)?

    Hi,
    My 60 GB iPod originally held over 12,000 songs (no video). I started deleting songs and adding new ones and realized deleted songs don't fully delete. I eventually ended up with a full hard drive and about 8,500 songs.
    I have now restored the iPod, using Apple instructions, and can't even get all the 8,500 songs back onto the iPod, never mind get additional usable space. What am I doing wrong? Many thanks for any helpful response!
    IBM Thinkpad T40   Windows XP Pro   also IBM Thinkpad T41

    The number of songs doesn't depend the actual number of songs, it depends on the size of the songs in terms of their file size (the amount of space they take up on the hard drive). Also if the songs have a higher bit rate, they will take up more room.

  • I have purchased additional iCloud space.  It shows I still have space, however my iPad mini shows I don't have enough space for the update for ios7.  My photos are in the cloud, I guess,  so why don't I have enough space?

    If I delete photos on my iPad mini, can I still see them in iCloud storage?  How do I free up more space on my iPad  without removing photos?

    If you delete photos from your iPad, they will also be deleted from iCloud and you'll lose them.  Also, having additional iCloud space won't give you any more space on your device.   You can't move any data to iCloud and delete it from your device.  All you iCloud data is also on you device, and if you delete it from your device, it is also deleted from iCloud.
    One option to free up space for the update is to delete the music from your iPad, then sync it back using iTunes after you update.   (You can delete it all by going to Settings>General>Usage, wait for the apps list to open, then tap Music>Edit, then tap next to All Music.)
    Also, if you purchsed the iCloud storage upgrade in the last 15 days thinking you chould use it to free up space on your iPad, you can call the Apple online store for your country and get a refund (1-800-MY-APPLE in the U.S. and Canada.)

  • How to create a error message for Deleted batch while creating a PO

    Hi ,
    Can any body tell me how to create error message for a deleted batch while creating a PO in ME21n,
    when a PO is created for a deleted batch at GI &GR lebel it is showing  a error message,
    but i want to show a error message while doing the PO creation.
    Thanks,
    Sachhi

    in badi  me_process_po_cust u can  put this message
    METHOD if_ex_me_process_po_cust~check.

  • PreparedStatement space and empty String

    Hi, I have this problem:
    PreparedStatement bookedQtyPS = null;
    String qry="SELECT * from djwsearch where djwitem=?;
    bookedQtyPS = conn.prepareStatement(qry);
    if(item.equals(""){ //item is an empty String
    bookedQtyPS.setString(1," "); // I set space instead of empty String
    }else{
    bookedQtyPS.setString(1,item);
    My problem is that I need to set space insteadOf empty String, but I think that I can not use PreparedStatement to do this. I have performance problems (my query is much more complicated than this one) so I choose PreparedStatement and not Statement.
    How can I do? Is this bug solved using PreparedStatement?
    Thanks.

    you can do it with the help of PreparedStatement.
    Here the type of field(djwitem) and setmethod is should be match..i mean if the type of ur field is String then you need to use the setSting method.
    you can do one thing specify one string variable.
    String space=" ";
    and now put this sapce variable at the second parameter of setString method.

  • Deletion of extra space in ALV report output

    Hi Experts,
    I have one issue where i have to delete the extra space in the output of  ALV report.
    Please let me know the possible way... Its very urgent.
    Thanks in advance
    Siri

    Hi Siri,
    Try these following steps in your report...... i think, it will lead you to solve your problem.
    1. Give output length of alv column as 10.
    2. OUTPUTLEN is there in Field catalogue
    3. "gt_layout TYPE lvc_s_layo" -  use this one field col_opt
    Reward if useful.
    Regards,
    Harish

  • How to delete the last char in a String?

    i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?

    Try it in this way
    String MyString = "ABCDEF";
    MyString = MyString.substring(0,MyString.length()-1);

Maybe you are looking for

  • Best practice on mailbox database size & we need how many server for deployment exchange server 2013

    Dear all, We have  an server that runs Microsoft exchange server 2007 with the following specification: 4 servers: Hub&CAS1 & Hub&CAS2 & Mailbox1 & Mailbox2  Operating System : Microsoft Windows Server 2003 R2 Enterprise x64 6 mailbox databases 1500

  • Database Design for Multiple function site

    Hi I am working on one project which involve multiple function site, such as Company Product Catelog, Customer Support Forum, Document Exchange Engine and etc... Normally we will combine ALL TABLEs into one DATABASE. My question are: 1) Is my break t

  • Transferring data from 9300 to E90.

    I currently have a 9300 and am looking to change to the E90. When I upgraded from the 9210i to the 9300 the process was easy enough to transfer my data. Before I buy the E90 is it possible to transfer all my data, via the backed up copy or with the a

  • Wi fi not connected message

    My ipad 2 wi fi is not working,  I get a Not Connected message.  Has anyone had this problem? if so what is the solution to be able to reconnect. Thanks

  • Inheritance in BPEL

    Hi I would like to develop a BPEL process and customize is to several clients. It would be very helpful if there was a way to override some behavior in the derived process. Of course people will argue about: (1) Use functional decomposition. That is