Ignoring extra characters...

Hi,
I'm creating a method where when you input a number in the String it ignores the extra characters.
For example...if i enter "-4.414E-80EEE", i should get "-4.414E-80", but i get "-41480.0".
Here's my code:
   public double convertDouble1 (String value)
       for(int i = 0; i < value.length(); i++)
           while (true) {
               try {
                   int number = Integer.parseInt(value);
                   break;
                catch (NumberFormatException ignore) {
                    value = value.replaceAll("[^0-9]"," ");
        return Double.parseDouble(value);
    }Anyone know where i'm going wrong?

LevelSix wrote:
For example...if i enter "-4.414E-80EEE", i should get "-4.414E-80", but i get "-41480.0".
Here's my code:
   public double convertDouble1 (String value)
for(int i = 0; i < value.length(); i++)
while (true) {
try {
int number = Integer.parseInt(value);
break;
catch (NumberFormatException ignore) {
value = value.replaceAll("[^0-9]"," ");
return Double.parseDouble(value);
>
Then I said:
Come on dude, think about this for a second.
look at that replaceAll() call, what is it doing.
hint: print out value each timeCounting from 0 to 9.No it is not. It is replacing every character that is not 0,1, 2, 3,4,5,6,7,8 or 9 with a space.
Can you explain to me why that's wrong?1) I don't think that is what you really want to do.
what about the decimal point?
what about the E separating the mantissa from the exponent?
What about the minus sign?
2) The while loop never ends.
How did you ever get the results you claimed from the code you posted.
When I ran it i just ended up with an inifinte loop.
3) For some you run the never ending while loop multiple times, once for each character in the string.
4) If you had printed of value each time as I suggested you would have seen what was going on.
Edited by: johndjr on Apr 14, 2009 2:16 PM
forgot about the minus sign (probably a bunch of other stuff as well)

Similar Messages

  • Technical issue SAP F110 related issue. getting extra characters in outgoing file from sap.

    Hi Technical guru's,
    SAP system creating a outgoing file through F110- t-code, this outgoing file has extra characters (DOC.NO:)
    We need to remove these extra characters. Once Payment run has been carried out through F110, in SM37 in job spool it is showing like screen attached with name “file from sm37”.
    But when we look in to outgoing file directory extra characters as I mentioned above is appearing below is the related screen attached with name “out gooing file”.
    Gurus can anyone please suggest me where I can check about this. I have checked the program available in the job as well in the F110 transaction.But could not find any hint.
    Programs which I find in SM37.
    SAPF110S
    SAPFPAYM_SCHEDULE
    RFFOSE_B
    Programs which are available in F110.
    RFFOAVIS
    RFFOEDI1
    RFFOSE_B
    Does extra  characters coming through functional configuration (DME configuration) or coming through SAP standard programs.
    I am Technical person. I need to solve this issue guys please help me in this.
    If above information is not sufficient  let me know what are the other information should I provide.

    I didn't get any resolution so far also I can't convert into Adobe form because this is a production issue which should be fix by making the requied setting or changes in SAP script itself we can't go for new developmet for this isuue.

  • BUG: Extra characters at the end of attachment file names

    I received complaints that my attachments didn't open on the PC's of the recipients. After I saw the messages I noticed there were extra characters at the end of their file names. That's why they wouldn't open. When I looked into my sent mail folder it was there as well. The addition took place when I sent the mail, while composing everything looked fine. It took me a while to realize the pattern. There was one extra for every non-ASCII character in the file name.
    Apparently Mail.app is using two different libraries. The other one counts the non-ASCII characters as two while the other doesn't. I don't know whether Finder still uses MacRoman or Unicode, but this seems to relate to double-byte characters.
    The short term solution is to use only ASCII for file names, but that's not what OS X is all about.

    The class files are broken. Recompile them. If you're uploading them, doublecheck if the FTP program used doesn't do mad things with binary files.

  • **Error** Scene 1, Layer 'actions', Frame 1, Line 664: 1087: Syntax error: extra characters found after end of program.

    Scene 1, Layer 'actions', Frame 1, Line 664: 1087: Syntax
    error: extra characters found after end of program.
    I am new to importing classes and I have been practicing
    making a photo gallery. I am stuck and I want to know if someone
    can help me with the error I am getting.
    If it is convenient, you can download and test my .zip at
    www.dhtmlguy.freeservers.com
    Thanks in advance!

    thanks...the small stuff gets me every time.

  • Extra characters at end of line in spool file

    I am trying to generate csv files from SQL Developer using queries written to spool files.  I have embedded the queries and associated set commands in script files and call them, as advised elsewhere.  This gives csv files that look fine, with headings and data comma separated and enclosed with double quotes.  The problem is that the files seem to contain a lot of extra characters at the end of each line.  They seem to be spaces, but not sure.  This is causing problems for the person trying to load the data.
    I'm using version SQL Developer 3.1.07.42, Java 1.6.0_11.
    Any ideas on how to avoid the extra spaces appearing?  Thanks for any help.
    Ben.

    Jeff,
    The SQL in the script file is below.  To be honest, I have reduced it down to a simple select from dual and it still puts extra spaces at the end of the single line.
    col ord noprint
    spool test.csv
    SELECT  ' ' ord,
      'ZONE_ORDER_NUMBER'||','||
      'ZONE_NAME'||','||
      'ZONE_TYPE'||','||
      'DESCRIPTION'||','||
      'START_DATE'||','||
      'END_DATE'
    FROM dual
    UNION ALL
    SELECT zone_name ord,
      '"'||zone_order_number||'"'||','||
      '"'||zone_name||'"'||','||
      '"'||zone_type||'"'||','||
      '"'||description||'"'||','||
      '"'||TO_CHAR(start_date,'DD-MON-YY')||'"'||','||
      '"'||TO_CHAR(end_date,'DD-MON-YY')||'"'
    FROM zones
    ORDER BY ord;
    spool off

  • Convert PDF font ITCFranklinGothicStd-MdCd add extra characters with CR2008

    My customer has several reports that are used the ITCFranklinGothicStd-MdCd font.
    We've had some users tell us that their reports are showing extra characters - specifically, it inserts the letter "i" after every lower-case "f". For example, 'Ref.' becomes 'Refi' and 'For' becomes 'Fior' (there's no letter "i" inserted after the capital "F" - it only inserts after lower-case).
    We've determined that the problem is due to the fact that we're using the ITCFranklinGothicStd-MdCd font; if we use a different font, it works fine. Also, if the end-user copies text from the generated PDF and pastes it into another document, it renders the correct spelling. So for example if they copy "Fior" out of the PDF and paste it into Notepad, it shows "For" as it normally should.
    We cannot change the font, but we should solve the problem.
    Use Crystal Report 2008 and Adobe Acrobat 9.
    How can I solve?

    Hi Ivan,
    This seems like it's PDF issue. You said "So for example if they copy "Fior" out of the PDF and paste it into Notepad, it shows "For" as it normally should."
    This suggests to me that PDF is having problem rendering that font.
    Do they have a TTF version of that font?
    What happens if you export to Word format, do you see it correctly?
    You may want to post your question to Adobe's forum and possibly the the makers of the font also.
    Thank you
    Don

  • Hyperlinks created in CS6 introduce extra characters

    I've noticed that when I create hyperlinks in InDesign CS6 (v 8.0.1) it adds extra characters in the URL, thus breaking the link. For example [red highlights problem areas]...
    Correct hyperlink typed into InDesign:
    http://portfolio.epri.com/ProgramTab.aspx?sId=ENV&rId=220&pId=6931
    InDesign renders the URL this way:
    http://portfolio.epri.com/ProgramTab.aspx%3FsId%3DENV%26rId%3D220%26pId%3D6931
    This happens on both a Mac and a pc. I never experienced this problem in earlier versions of InDesign.
    I found an earlier discussion about this problem but it doesn't appear that Adobe has fixed it. A corrective script was offered by Laubender in that discussion. However, I create a lot of docs with a lot of links and would rather avoid that type of solution.
    Any suggestions would be much appreciated.

    Use laubender's script solution. It is the most straightforward fix.
    http://forums.adobe.com/message/4463255#4463255

  • Contacts notes still have extra characters

    No device
    I have a pre that's 2 yrs old.  I have been reading that the extra characters  < br / >  issue is known; in fact 2 other posts from 2010 were closed.  I still have this problem; I added a contact 10 minutes ago and notes still added extra characters.  The extra characters have never gone away since arriving a year (?) or more?  any help coming?

    Hmm...
    OK - I just went into icloud settings on my iphone and figured I would toggle off the notes, back out and then go back and toggle notes back on... this was the one set of data that wasn't critical if I list it. 
    Notes came back, reminders are now back and contacts are now back... Still would love to know why these all disappeared in the first place.  All seems to be back to normal though. 

  • Add hyperlink in mail is adding extra characters to URL

    When I paste the add a hyperlink to a page called Recent News on my .mac site, extra characters are added to the url causing the page not to be found.
    "...Site/Recent%20News/D3A....html" becomes "...Site/Recent%2520News/D3A....html". I have no problem adding a hyperlink for my welcome page. Any ideas?

    I don't know how to fix it, but I can at least tell you what's happening. The "%20" is the encoding for a space character in a URL, " ". This is being turned into "%2520" because the "%" is being encoded as "%25" (the encoding for "%" in a URL), so "%20" is turning into "%2520".

  • Extra characters appearing in Stickies and TextEdit

    Having a problem with the design computer at work. Font issues all over the place. For instance, I'm trying to type into this field, and my cursor isn't exactly lined up with the text... so I don't really know where I am . It's inserting extra characters and spaces into the text field. This is happening on Stickies and TextEdit... and not anywhere else... not with Mozilla Thunderbird or MS Word. Weird.. Also the font is very light... as If I'm missing a core font.. which is possible because I used FontExplorer X (from LynoType) to clear the font cache and remove fonts from the system folder than weren't installed by Apple. I t may have screwed up the font folder... I might need to reinstall fonts, but I don't want to reinstall the system if I can avoid it. Any suggestions?
    Dual 2GHz PowerPC G5   Mac OS X (10.4.9)  

    Hi wlp165,
    Try printing the Word Doc to Adobe PDF printer and then check the issue.
    Or would it be possible for you to share the document.
    I sent you private message for sharing the document.
    Regards,
    Anoop

  • Permitted extra characters in BW

    Hi,
    we are loading material master data and get an error message:
    Charachter µ (lower case Mu) is not permitted. We are on BW 7.0.
    We didn't have any problem with BW 3.5 as we have maintained it in permitted extra characters in RSKC. I tried to copy extra characters (RSKC) from BW 3.5 in BW 7.0, but it doesn't work for Charachter µ (lower case Mu). It makes a capital M in RSKC in BW 7.0
    Any suggestions.
    Thanks

    In a UNICODE system it's doing the right thing. Remember that Mu (character µ) is M in the Greek alphabet, so the system is "translating" the character µ from Greek to M in English (capital M as you may have ALL_CAPITAL in your RSKC settings. This will also happen for ? (ALPHA) as A in English or ? (Beta) as B in English.
    Now the symbol µ was taken for the Micro symbol in the 255 ASCII table (non-UNICODE systems) so there's a "confussion" between the letter MU in Greek (UNICODE 03BC) and the Micro symbol (UNICODE 00B5).
    Try customizing the program to interpret 03BC to 00B5 or you may set the RSKC to ALL_CAPITAL_PLUS_HEX.
    Hope this works.
    Jesus
    Edited by: Jesus Cova Graffe on Feb 19, 2008 4:03 PM

  • PDFMaker bookmarks broken or extra characters

    My configuration:
    Windows XP SP2
    Acrobat 8 Pro
    Word 2000
    When I attempt to create bookmarks automatically using the options in PDFMaker, the resulting bookmarks are broken and the bookmarked headings have extra characters in front of them.
    By broken, I mean that the bookmarks all point to the same, incorrect page.
    The headings (and StyleRef fields in the headers) include extra characters of the form 0B, 1B, 2B, etc.
    This happens when I start Word without any other add-ins, and when I try to process a completely new, small, clean document with just a few headings.
    This happens when I use built-in headings and when I use custom designed headings.
    Any suggestions for fixes or workarounds will be appreciated!
    Bear

    Bill: Thanks for your suggestion. AFAIK we are using the last available update to Word 2000. And remember, it's not a problem in the DOC file -- it's only in the PDF when created with bookmarks.
    Here's my most precise formulation of the problem to date. I'll call the unwanted characters in the headers the "1B" problem.
    When you create a PDF with bookmarks from a document that uses a StyleRef to populate the headings, IF the StyleRef is for a built-in heading style, the "1B" problem appears. In our problem template, the headings are filled by StyleRef to Heading 1, a built-in heading style.
    If I create a custom style named H1 that is identical in all aspects to Heading 1 and use that for the topic title paras (paras that used to be Heading 1) the "1B" problem disappears.
    To recap, in the "fixed" version:
    H1 (used for the level 1 PDF bookmark) is a custom para style used for topic titles. Headers are populated via StyleRef to H1.
    Heading 2 is used for the level 2 PDF bookmark. (I expect any other built-in headings will work fine as well. It's just a conflict between built-in headings and StyleRef fields.)
    This leaves three solutions:
    1. Revise the style definitions in the template to use a custom style for topic title paras.
    2. Remove the header from the template design
    3. Create bookmarks manually.
    I'm inclined to remove the headers, as this is a medium-sized manual that isn't divided into chapters, and it's of marginal value to the reader to put the topic titles in the page headers when there are so few topics, and they are each only few pages long.
    I don't expect a solution in the form of an upgrade or patch for either Word 2000 or Acrobat 8. Word users on the Word-PC site experimented for me, and we were able to reproduce the problem in Word 2007 and Acrobat 8. I suspect it's there with Word 2003 as well.
    Bear

  • Deleting extra characters

    Is there a way to delete extra characters in a StringBuffer after the first occurance? For example, if I wanted to delete all comma's after the first occurance in a string, this seems to work:
              if(custName.lastIndexOf(",") > custName.indexOf(","))
                   custName.replace(' ,' , ' ');
    But how would you do this in a StringBuffer? I have tried using something like this:
    int numComma = 0;
    for(int i = 0; i < letter.length(); i++)
    if(letter.charAt(begin) == ',')
         numComma ++;
    if( letter.charAt(begin) == ',' && numComma > 1)
         letter = letter.deleteCharAt(begin);
    but it deletes all commas, including the first occurrance..Would you use the same approach to delete extra spaces between words?[if there is more than one space] Any suggestions would be appreciated..

    if you use java.util.stringtokenizer you can tokenize by your delimiter.

  • Error 1087 extra characters found after end of program.

    Why am I getting the "error 1087 extra characters found after end of program with this code".
    If (counter == 1) {
    Next_btn.addEventListener(MouseEvent.CLICK,KMT1);
    else {
    Next_btn.addEventListener(MouseEvent.CLICK,KMT1);
    function KMT1(event:MouseEvent):void {
      gotoAndPlay("KMT1");

    thanks...the small stuff gets me every time.

  • Printing pdf - extra characters added

    When printing from a downloaded pdf to another pdf or to hardcopy on our HP printer, extra characters are being added.  For example, the letter "j" is being added to the end of every word in one italicized paragraph, while a ":" is being added to the end of every word in another italicized paragraph.  The problem does not occur for all italicized items or paragraphs, only some.  I'm using Acrobat Professional 8.1.4.  This problem does not occur when using Acrobat 5 (which we have on one computer here for various reasons).  I've tried optimizing and flattening but they seem to have no effect.  Any ideas?  (There is no way to access the original source document used to generate the original pdf - I have re-downloaded it with no change.)

    Try updating AA8. It is currently at AA8.2.3. May not solve the problem, but worth the try.

Maybe you are looking for