Stripping extra white space from a string

I am trying to strip extra spaces from a string, so it there are 2 or more spaces between a word I want to remove all but one. I am trying the following code
getStringTwo().replaceAll("/\s+/is","");
but all I get is an error saying Invalid escape sequence
Thanks
G

>
This strips out all the whitespace. I ended up
getting round it by walking through the string and
checking the values of each char and comparing that
to the next value. What a wast of effortt A small modification of my earlier post gives -
public class Test040320a
    public static void main(String[] args)
        String str = "this    is       a \t test";
        str = str.replaceAll("\\s+"," ");
        System.out.println(str);
}

Similar Messages

  • 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();

  • Remove extra white space from an image

    I want to remove the extra white space in my image while writing it into a jpeg file using JPEGImageEncoder.
    Any help is welcome .

    ok.. Am having a JPanel whose width is set to 77000. But almost 60% of right hand side of the Panel is empty. I will create a BufferedImage from this component and then write it into a file using JPEGImageEncoder.
    The empty portion of the panel is coming as a white space in the image.
    Now how to remove this ? Was that clear enough ?

  • How to extract ALL text on a line, including extra white space, from PDF?

    I have written my first scripts to parse thru PDF files and successfully locate the beginning and ending of text portions that I wish to copy/extract.  For example, one of the scripts reads thru PDF files and locates patterns that allow me to copy/extract a lengthy Title that spans several lines on the page.  My remaining problem is that sometimes the text I wish to copy/extract has tabs or lots of white space between the words, and I need to retain ALL the "white space" between words.  Basically, I am successful at using getPageNthWord(j, i, false) along with "Quad coordinate sets" to get a word-at-a-time for all the words on the multiple lines but it seems to be skipping over the tabs and extra white spacing beetween the words.   Another way to say this is that I need to extract/copy a full line at a time, including all white space, instead of being limited to just a word at a time. 
    Can anyone help me with an algorithm to extract/copy text, not just the words but also including tabs and other extra white space characters? Is there some type of Regular Expression I should be using, or maybe some additional parameter used for getPageNthWord that would retain all the extra white space?
    Thanks in advance,
    Ted L

    Did you try setting the bStrip parameter of getPageNthWord to false? It will
    preserve some of the whitespace, but not all of it.
    As far as I know, that's the only way to do it via a script.

  • Extra White Space from Hidden Menu Bar

    This seems to be a problem introduced by LV 2013. I have a VI that runs with the menu bar hidden. When I hit ctrl-m to see how it looks in run mode, it looks fine. When I run the VI, instead of fully hiding the menu bar, it leaves white space. This only seems to be a problem when the VI is the top level. When the VI is opened from another VI, it looks fine. I've attached screenshots when the VI is running as a top level, ctrl-m is used and running when launched from another VI. This was not an issue in LV 2012. It's only been a problem since switching to 2013.
    Solved!
    Go to Solution.
    Attachments:
    Settings Screen Running Dev.png ‏86 KB
    Settings Screen CTRL-m.png ‏84 KB
    Setting Screen - Launch as SubVI.PNG ‏107 KB

    Greetings thutch79,
    I replicated the settings shown at Window Appearance Dialog.png on a new VI, ran it, and did not reproduce the problem.
    I wonder if you experience the same behavior with a new VI? If not, you can copy paste the code to a new VI to fix a potential corruption issue.
    Regards,
    Alejandro | Academic Program Engineer | National Instruments
    Attachments:
    Window Appearance.JPG ‏119 KB
    Running VI.JPG ‏21 KB

  • Extra white space in Firefox, not IE

    Hello. I'm new to Dreamweaver and am having an issue I can't
    figure out. I was hoping someone might have insight into where my
    problem is.
    In the following site,
    http://www.firststepshr.biz,
    it previews as designed in Internet Explorer. However, in Firefox,
    extra white space (or blue background on the home page) is
    appearing above and below the Flash header. I can't, for the life
    of me, figure out why there's this difference.
    Anyone have any ideas? Thanks, in advance, for the advice.
    Jeremy

    I don't see extra white space in FF2x.
    If you want to use Flash for navigation, consider this -
    1. Some people don't have Flash installed - what do they do?
    2. Search engines may not parse Flash links - your site will
    not be
    spidered
    3. Screen assistive devices don't parse Flash links - what
    will those users
    do?
    4. DW cannot maintain links within a Flash movie, so if you
    move or rename
    a linked file, your navigation will break - what will you do?
    You will have
    to remake those buttons.
    It's usually a very bad idea for these reasons - and for
    these reasons,
    Adobe has removed Flash buttons and Flash text from the next
    version of
    Dreamweaver.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "dwellingproductions" <[email protected]>
    wrote in message
    news:gckfd0$odl$[email protected]..
    > Hello. I'm new to Dreamweaver and am having an issue I
    can't figure out.
    > I
    > was hoping someone might have insight into where my
    problem is.
    >
    > In the following site,
    http://www.firststepshr.biz,
    it previews as
    > designed in
    > Internet Explorer. However, in Firefox, extra white
    space is appearing
    > above
    > and below the Flash header. I can't, for the life of me,
    figure out why
    > there's this difference.
    >
    > Anyone have any ideas? Thanks, in advance, for the
    advice.
    >
    > Jeremy
    >

  • Extra White Space issue

    Hi, I am currently building a website in Adobe Muse, and am really enjoying it.  I have encountered a few differences between what I designed and what the site actually looks like and have been able to find solutions to all but one.  The home page has just a header and footer and an Adobe Edge Animation.  However, there is extra white space apearing underneath the animation (above the footer). Everything looks fine in the design mode, but even in preview there is extra space.  I tried uploading it to our ftp, thinking that might be the issue (as the animation doesn't show in the preview mode), but the extra space is still there.  I tried moving the Social media icons, thinking they might be causing it.  I have looked to see if maybe there is a text box, or empty shape that is causing the discrepency, but I can't find anything.  Any suggestions?
    Here is the screen capture of the design mode:
    Here is the screen capture of it in the browser:
    Any help would be greatly appreciated.

    Hi Razorcs,
    I have checked your file and the white space is coming from the page that you are calling in the iframe. I have seen that most browsers do not respond well, when the widht and the height of the iframe is specified in percent.
    As a fix you have to give manual width and height to the iframe and that should take care of it.
    For example, try something like 412px, which is the height of the edge content,
    Regards,
    Abhishek Maurya

  • Placed Illustrator PDF has extra white space

    Illustrator  artwork saved as PDF, and placed on an InDesign page comes in with extra white space of around 1 1/3 mm on all 
    sides. I can't figure out what this unwanted white space is or how  to avoid it. Can someone please tell me how to avoid the  extra white space.

    in which case - i can only apologise for the incorrect advice.
    I've never had any problems with eps files - providing that the artwork is tidy.
    And I've found loads of problems printing a placed pdf through a digital rip.
    I'll leave it down to trial and error... and wish the best of luck.
    cheers
    re

  • How do I remove the white space from the bottom and side of my document?

    How do I remove the white space from the bottom and side of my document? (I'm not talking about printing, just viewing it on the screen.) There are about 6 inches of white space at the bottom and at the right hand side. I don't like this. On a blank new spreadsheet it's triple that amount of white space.

    The infinite canvas convention doesn't make a lot of sense for Numbers. When I'm viewing a spreadsheet and mistakenly scroll into white, empty space I think, "this is ridiculous - all of my content is fits on one screen. there's nothing over there."
    A (relatively) infinite canvas is logical for Microsft Excel because it's one big table. There are 256(?) columns by default and hundreds of rows on a sheet - there are cells outside what a user is looking at to see. However, when viewing a Numbers spreadsheet with a single 10 column 10 row table that fits on the screen, there's nothing else on it to scroll to.
    Numbers should distinguish between viewing a spreadsheet and editing one. When I'm just viewing, when there's no content outside the window it shouldn't scroll there. This window behavior is beyond annoying for Numbers on my iPad and iPhone.
    (Adding user-defined canvas size setting to my view mode / edit mode thinking would probably be the most complete solution to this now that I think about it.)
    Until now the way scrolling worked in Numbers has defied logic. Actually it still does lol. That said, thank you Yellowbox for providing a clear explanation. Much appreciated.

  • Conditional Build Tab for image leaves extra white space

    I've applied the "Print" Conditional Build Tag to an image in
    my online help. When I generate the help and view it in the
    browser, extra white space is inserted between the steps. For
    example, instead of the steps being:
    1.
    2.
    3. etc.
    They now look like this:
    1.
    2.
    3. etc.
    Why is there extra white space where the image used to be?
    Thanks in advance for your help. Using RoboHelp7 -- WebHelp.
    Bill

    Probably there is a paragraph break or a space that you can't
    see but is not enclosed in the conditional tag.
    Check the html code immediately before and after the tag.
    Harvey

  • Why is there extra white space at the top of swf file?

    I can't figure out how to get rid of extra white space in the browser at the top of a swf file. It looks fine when I preview the file, but when I do publish preview in flash/ try to incorporate in HTML, there's an extra 1/4" at top of window.

    Do you have the html page (that you have the swf file embedded into) set so that there are no page margins? Your "body" tag should look like this…
    <body leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">

  • Why is there extra white space on below the navigation bar?

    I am running Nightly 6.0a1, and for the past few days, there has been extra white space under the Navigation Toolbar, as though there is an extra empty toolbar. The only toolbar I have is the Navigation Toolbar. BTW, this happens w/ tabs on top and bottom. Here's a screenshot: [http://i1004.photobucket.com/albums/af162/cg2916/extraspace.png http://i1004.photobucket.com/albums/af162/cg2916/extraspace.png]

    Do you see any toolbars listed in "Nightly > Options" that are visible but do have a check mark?
    See also:
    * http://kb.mozillazine.org/Corrupt_localstore.rdf
    Did you try a new profile?

  • Issues in Application table - extra white space with and without scroll bar

    1. There is an extra white space that comes after the last column in all the applications table, when there is no scroll lbar.
    [http://files.oraclecorp.com/content/Private/Screenshots/Space_ApplicationTable.bmp]
    2. If the scroll bar comes up then, there is an extra white space on top of the scroll bar.
    [http://www-apps.us.oracle.com/~jkodiyan/fusion/screenshots/appstablespace1.jpg]

    It would be best to follow this up in your internal ApplCore / ADF frontend forum..
    screenshot for issue #1: http://www-apps.us.oracle.com/~jkodiyan/fusion/screenshots/appstablespace2.jpg
    That's an internal Oracle URL - Probably not a good idea to share on the internet and it's not accessible outside anyway...

  • Extra White Space Around Header Graphic & NavBar

    I have a header graphic and Navigation Bar (rollover images)
    positioned inside a table. Unfortunately, there is about 1-2 pixels
    of white space on the left, right, and top of the header graphic.
    Same with the NavBar--there's 1-2 pixels of white space on the
    edges (left & right sides). By default, cell padding for the
    table is set to zero. If cell padding is set to zero, why am I
    seeing white space between the edge of the graphic and the edge of
    the table?
    You can see what I'm referring to here:
    http://newstartinvestment.com
    What is causing this extra white space, and how do I get rid
    of it?

    On 26 Mar 2007 in macromedia.dreamweaver, csbridges wrote:
    > I have a header graphic and Navigation Bar (rollover
    images)
    > positioned inside a table. Unfortunately, there is about
    1-2 pixels
    > of white space on the left, right, and top of the header
    graphic.
    > Same with the NavBar--there's 1-2 pixels of white space
    on the edges
    > (left & right sides). By default, cell padding for
    the table is
    > set to zero. If cell padding is set to zero, why am I
    seeing white
    > space between the edge of the graphic and the edge of
    the table?
    >
    > You can see what I'm referring to here:
    >
    http://newstartinvestment.com
    (Btw, I
    > don't like the yellow rollovers--they'll be removed
    shortly.)
    >
    > What is causing this extra white space, and how do I get
    rid of it?
    Personally, I thought that the white border was a feature,
    but... In
    addition to the cellpadding, add cellspacing:
    <table width="780" border="0" align="center"
    cellpadding="0"
    cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
    Joe Makowiec
    http://makowiec.net/
    Email:
    http://makowiec.net/contact.php

  • Why is there extra white space after exporting to JPEG?

    After exporting an *.ai file to jpeg using  150 ppi and 5 for compression, I have extra white space below the artwork. This has happened in two files after exporting.

    Urthie,
    What about the Artboard, is that aligned to the Pixel Grid (it is if the size is a whole number of points/pixels and one corner is at X=Y=0 or another set of integer values, otherwise not)?
    Edit: Cross posting.
    Congratulations, some things are difficult to spot (and guess for others); your finding the solution is the best happy ending.

Maybe you are looking for

  • Uploading Video Directly to Internet

    I am shooting some video for a company who wants me to upload the video to their website afterwards. I don;t want to have to "upload" to my iMac and then transfer it to the website, but go directly from camera to website through the iMac. The website

  • Use ArrayList vs Vector

    I'm writing an application that accept multiple connections. To check the connections I have a thread that check these connections if they are in use, i iterate over these connections and if they are not used for a periode of time, i close this conne

  • Save as xml

    I have an html form with 10 fields, I want to save the info in a database field (a blob) as xml, is there an extension to do this ? And then I have a page with same fields but to display the info from the database (xml) each value of xml where the fi

  • Error in Tax

    Dear SAP Guru's I have configured the depot & tax is getting calculated properly but it is giving a warning message as in condition tab at order level. for intra state order "Error during transfer of tax condition JIP6 Message no. VH807 Diagnosis A c

  • Set Active Directory Folder Permission

    We have added a Lion server to an active directory domain, however I cannot determine how to set Active Directory permissions on shared folders on the Mac. Ideally we want our windows users to access shared folders on the Mac however we would like to