How do I get rid of leading zeros.....

Hello...
Here's what I am trying to do....
1. I get a file like below
00000000000.00 00000000000.00 00000036092.80
00000000000.00 00000000000.00 00000000240.00
and more lines depending on the how big the files are(possibly to have 1 million records)....
All I am trying to do here is getting rid of the leading zeros in record like below(they are amount of dollars)....
0.00 0.00 36092.80
0.00 0.00 240.00
What would be the best way to do this, assuming it will not clog the system.
Thanks,
Jay

import java.io.*;
import java.util.regex.*;
import java.util.*;
public class Example
   public static void main(String [] args)
      String line1 =
         "00000000000.43 00000000000.00 00000036092.80";
      List list = Collections.nCopies(1000000, line1);
      long time = getRidOfZero(list);
      System.out.println(time);
   public static long getRidOfZero(List lines)
      // This regex matches a bunch of 0's and then a decimal number.
      // It requires at least one digit before the decimal; this takes care
      // of 0.00 and handles the normal cases like 00243.06.
      String regex = "0*(\\d+?\\.\\d+)";
      Pattern p = Pattern.compile(regex);
      Matcher m = p.matcher("");
      long elapsedTime = 0;
      String line;
      long start = System.currentTimeMillis();
      for (Iterator i = lines.iterator(); i.hasNext(); )
         line = i.next().toString();
         m.reset(line);
         line = m.replaceAll("$1");
      long end = System.currentTimeMillis();
      m.reset();
      String rep = m.replaceAll("$1");
      System.out.println(rep);
      return end - start;
}

Similar Messages

  • How can i get rid of the zeroes after sub-division of arrays?

    Hi
    i have sub-divided a long 1-D array (50000 samples) into a number of smaller sub-arrays with different lengths build in a 2-D array. What happened is, where the sub-arrays end, Labview adds zeroes to them to match the length of the biggest array (558 length). How do i get rid of the zeroes?I just need to have the actual length of each sub-array with now zeroes to it. I have attached my vi
    Thank you
    Attachments:
    Untitled2.vi ‏419 KB

    Hey guys,
    when posting examples, don't retain bad programming, even if it only occurs as a side issue. New LabVIEW users will copy everything posted here as gospel!
    Ben's workaround is sound, but please refrain form keeping a "cruncher loop". An empty loop without wait will consume all CPU and possible starve all other running processes for no good reason. That polling loop needs a small wait statement!
    An empty loop without any wait statement will:
    Will spin millions of times per second using 100% of the CPU.
    run many iterations before allowing a thread switch.
    Add 10 such loops in any program and the program will be unusable (thread gobbling!).
    Even a 1ms wait will reduce the CPU consumptions by many orders of magnitude.
    Even a 100ms delay will not noticeably delay any user actions.
    Waiting for a button press is not something that needs to be handled within nanoseconds.
    Cruncher loop!
    Easy correction: place a smal wait inside that loop!
    Message Edited by altenbach on 04-11-2007 05:12 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    cruncherloop.png ‏12 KB

  • Getting rid of leading zero using display string.

    I have a formula:
    If {BillHeader.SalesTax} < 0 then
    formula = Replace(CStr (-1 * {BillHeader.SalesTax}), "$", "") + "CR"
    else
    formula = Replace(CStr ({BillHeader.SalesTax}), "$", "")
    end if
    I need to change this formula so it won't show a leading zero.
    ex:
    0.00 to .00
    0.47CR to .47CR
    etc..
    I don't have much experience with VB or crystal code.  Since this is in the display string I can't use the number formatting.  Any ideas? Thanks for the help!

    Here is one solution:
    1.  Comment out the display string code.
    2.  From the menu, choose "Crystal Syntax".
    3.  Copy and paste this formula.
    If currentfieldvalue < 0 then
       if split(Replace(CStr (-1 * currentfieldvalue), "$", "") + "CR",'.')[1] = '0' then
          '.' & split(Replace(CStr (-1 * currentfieldvalue), "$", "") + "CR",'.')[2]
       else
          Replace(CStr (-1 * currentfieldvalue), "$", "") + "CR"
    else
    if split(Replace(CStr (currentfieldvalue), "$", ""),'.')[1] = '0' then
       '.' & split(Replace(CStr (currentfieldvalue), "$", ""),'.')[2]
    else
       Replace(CStr (currentfieldvalue), "$", "")
    PS:  In your first formula, you are using sales tax but in the second post, you are using amount due, not sure which one it is, but if the formula is on a display string the above should work.

  • I have a Australian iTunes account and want to switch to using the u.s store as I now live there, I cannot do this because I have $1.41 still in the oz account an image to have a zero balance to change stores, how can I get rid of the $1.41?

    I want to switch to the u.s store as I now live in the us, I cannot switch stores because my balance is $1.41 in the oz store and needs to be zero, how can I get rid of the $1.41 when everything costs more or less than that? I do not have a credit card on the oz iTunes account an I cannot use my us one to top it up.
    HELP

    Click here and request assistance.
    (60992)

  • I am using the old imovie HD on my old Mac laptop... it works fine, but when I export a video to YouTube there is a black frame around it.. how do i get rid of that? thanks!

    I am using the old imovie HD on my old Mac laptop... it works fine, but when I export a video to YouTube there is a black frame around it.. how do i get rid of that? thanks!

    Hi MyAppleID99,
    You may want to check to make sure the clip hasn't been moved back and forth between wide screen and standard aspect ratios; sometimes a combination of letterboxing and pillarboxing can lead to a black frame "windowbox" when playing the final video. You may find the following article helpful:
    Apple Support: What are Letterboxing, Pillarboxing and Windowboxing?
    http://support.apple.com/kb/ht2320
    Regards,
    - Brenden

  • How do I get rid of the small change in my account that is stopping me from editing my home country in my i tunes account

    How do I get rid of small  money change in my USA  i tunes account so that I can edit my Country back to Canada  to use my Canadian i tunes card to purchase songs from the i tunes store. I have no USA credit cards and Pay Pay  is not working as well.

    Click here and ask the iTunes Store staff to zero your account balance.
    (114983)

  • How do i get rid of the 5 cents on my itunes account,

    How do i get rid of the 5 cents on my itunes account. I want to change the country settings on the app store

    Contact the Mac App Store support and reqest to have your account zero balanced so that you are free to change the country that your account is associated with.
    Mac App Store Support -
    http://www.apple.com/support/mac/app-store/

  • How do I get rid of the white border that prints on my pictures?

    Lightroom 2 - Windows 7 64-bit - Nikon D700
    I have just downloaded my Lightroom software to my new computer which runs Windows 7.  I had lightroom on my old Vista computer and just had to change the border size to remove it from my pictures, however, for some reason it will not let me remove it anymore.  When I try to adjust the border size it states it cannot be smaller than .2.  Therefore, I have a white border around all my pictures I am printing.  HELP!  How do I get rid of this border.  Thank you so much for the help.

    Make sure you select a borderless papersize in the page setup. That will allow Lightroom to set the margins to zero. Otherwise it sets it to the minumum value the printer tells Lightroom it can print at at the current print size. Your printer and driver need to support borderless printing for this to work.

  • How do you get rid of 'empty' pre-roll time in logic pro 9?

    how do you get rid of the pre-roll time in logic pro 9?  
    My project's start time is 8-bars before any material, or tempos, or anything...  
    Can't move the start time back to ")" (zero)    STUCK!!  at -8
    The song now has 20 seconds of dead air time in a pre-roll.
    None of these worked or revealed anything...
    -tried making a new copy of song
    -looked into every track's file information looking for a spurious entry
    -tried deleting the time/space

    Hi
    Check for any Track Automation nodes in the "preroll'.
    CCT
    Edit
    You should note that generally negative (or zero) project start numbers should be avoided at all cost: there are many peculiar behaviour problems associated with them.

  • How can I get rid of my own contacts from my wife's contacts list?

    Somewhere along the way my wife's contacts app on her iPad, her Mac and iCould, was populated with all of my own contacts (lots). How can I get rid of mine without deleting her own. I have backed up her contacts on the Mac and I have checked that new contacts are not appearing on each other's lists. Hers is an iPad 2 running iOS 8.1.1. The Mac is running Mavericks.

    Contact iTunes Support and request that they zero out your account balance.
    iTunes Support -
    http://www.apple.com/support/itunes/

  • How do I get rid of the back-up on Time Machine?

    Got rid of a computer, how do I get rid of the back-up on Time Machine (housed on a Time Capsule)? Can I safely just delete the sparsebundle file?

    It is much easier, and much faster, to erase the Time Capsule drive if you do not have other backups on the drive.
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click the Time Capsule icon
    Click Edit
    Click the Disks tab
    Click Erase Disk
    The Quick Erase option will be fine and will only take a minute or two
    If you do not plan to hold onto the Time Capsule use the Zero Out option, which is more secure
    If you do have other Time Machine sparsebundle files on the Time Capsule and do not want to erase them, then you will need to manually delete the sparsebundle file that you no longer need.
    It will likely take about as long to delete the file as it took to make the first backup.

  • How can I get rid of $0.11 in my app store?

    How can I get rid of $0.11 in my app store? I need to change my region but I wont be able until the balance is 0

    Click here and ask the iTunes Store staff to zero your account balance.
    (113051)

  • How can I get rid of "myV9" that suddenly appeared the other day when I started Firefox?

    Suddenly there was a portal site named "myv9" or "V9" on the screen when I started Firefox the other day. It contains a lot of icons for programs like Facebook, Google and so on. Until now I have had only Google as start page from Firefox. Of course I can click on the Google icon to get there, but it is the only site that I want to use of all these. Nearly all the other icons (except Facebook and some others) lead to specific US sites that I never visit (for example the weather forecast for North America) , because I live in Sweden. How can I get rid of "myv9"?
    Even if it doesn´t harm my computer, I am afraid that it will slow it down, and, besides, it needs an extra click to get to Google.
    Vidar Ferm, Sweden

    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    You can also do a check for a rootkit infection with TDSSKiller.
    *http://support.kaspersky.com/viruses/solutions?qid=208280684
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Can't get rid of Net Zero!

    Hi everyone,
    I have just graduated from dial-up to broadband, and although I have called and spoken to Netzero about canceling my account, I cannot get them off of my browser when I first open it. I have set my default to gmail, and that screen comes up first, but then there is the Netzero tab starting up right next to my gmail tab. I am using Firefox. I have deleted the Netzero application from my hard drive, but still haven't had any success. Does anyone know how I can get rid of the Netzero tab that keeps coming up? These are pretty pesky folks when it comes to canceling accounts. I'd be grateful for any help anyone can offer.
    Thanks!

    Hi Carolyn,
    First of all may I say please make another angry but informed email to Net Zero outlining your problem and how they are completely responsible for giving means to remove their software from your computer.
    That being said try resetting the Firefox preferences file and see if that helps.
    /Home/Library/Preferences/org.mozilla.firefox.plist

  • Ipad shows email but I do not have any how do I get rid of it

    How do I get rid of the email notification when I do not have any

    You don't need a computer to use an air printer with your iPad.
    See requirements for AirPrint and printers that support AirPrint here:
    http://support.apple.com/kb/ht4356
    If your printer supports AirPrint but does not work then:
    Your printer might need a firmware update
    Your printer must be on the same WiFi network
    Your router must support Bonjour (Zero-configuration networking).
    Troubleshooting:
    Turn Off iPad, WiFi router (remove from power), and Printer (remove from power).
    Turn on WiFi router
    Wait 30 seconds
    Turn on printer
    Wait 30 seconds
    Turn on iPad
    Try to print.
    If you need more help then what model printer do you have?

Maybe you are looking for

  • Line after  text in smartforms display

    Hi , Issue 1: I want to display a line after a text. Ex: Name _______________________________________ I am unable to display the line till the end of the page. When I save and activate, the line gets shortned itself as below.      Name ______________

  • How to get the baselinegrid position for a line?

    Hi All, How to get the baselinegrid position for a line in a paragraph?

  • Does Lion work with FCP 6?

    Hello, I want to purchase a Mac Book Pro 13 or 15 " computer; however, I have FCP 6.  Will Lion, the new OS system, work with it? Any feed back will be welcome. Thanks

  • How to fix error 2063 in muse

    how to fix error 2063

  • Sample BPEL processes

    I want to know where are the sample BPEL processes located. There are some samples that are in dev kit but they are all invoked from Workflow to do some other operation not related to OCS.