Matcher and Substring what's wrong?

I'm trying to read in a large file. I have decided to do regular expressions and use the Pattern and Matcher.
It works great but for some reason it doesn't get all the text between the REB.
                         while ((line = bdr.readLine()) != null) {
                    lineLength = line.length();
                    lineNumber =  i;
                    pat = Pattern.compile("REB");
                    mat = pat.matcher(line);
                    while(mat.find()) {
                         System.out.println("  ");
                         if(checkIndex(line, mat.start()) && checkIndex(line, mat.end()+4))
                              bookName = line.substring(mat.start() + 4, mat.end() + 4);     
                         System.out.println("Book:" + bookName);
                         if(intEnd != mat.end()) {
                              intStart = intEnd;
                              intEnd = mat.end();
                         System.out.println("Start Index:" + intStart);
                         System.out.println("End Index:" + intEnd);
                         System.out.println("Line Number:" + lineNumber);
                         System.out.println("Last Index in Line:" + line.lastIndexOf(line.charAt(intEnd)));
                         System.out.println("Line Length:" + line.length());
                         if(intEnd > intStart) {
                              text = line.substring(intStart, intEnd);
                         } else {
                              text = line.substring(mat.start(), line.length());
                         System.out.println("Text:" + text);
                    i++;
               }My problem is it seems to skip 1.5, it will get 1.4 and 1.6. Is there something I'm missing? or doing wrong?
The output I get from doing this is this:
Book:Gen
Start Index:0
End Index:3
Line Number:11
Last Index in Line:11
Line Length:15
Text:REB
Book:Gen
Start Index:3
End Index:10
Line Number:12
Last Index in Line:676
Line Length:681
Text: �1�REB
Book:Gen
Start Index:10
End Index:184
Line Number:12
Last Index in Line:676
Line Length:681
Text: Genesis 1.1�IN the beginning God created the heavens and the earth.1:1�2 In . . . earth was: or When God began to create the heavens and the earth, 2the earth was.���1.2 REB
Book:Gen
Start Index:184
End Index:400
Line Number:12
Last Index in Line:676
Line Length:681
Text: Genesis 1.2�The earth was a vast waste, darkness covered the deep, and the spirit of God hovered over the surface of the water.1:2 the spirit . . . hovered: or a great wind swept; or a wind from God swept.���1.3 REB
Book:Gen
Start Index:400
End Index:473
Line Number:12
Last Index in Line:676
Line Length:681
Text: Genesis 1.3�God said, �Let there be light,� and there was light; 1.4 REB
Book:Gen
Start Index:473
End Index:563
Line Number:12
Last Index in Line:676
Line Length:681
Text: Genesis 1.4�and God saw the light was good, and he separated light from darkness. 1.5 REB
Book:Gen
Start Index:563
End Index:3
Line Number:13
Last Index in Line:11
Line Length:15
Text:REB Genesis 1.6
Book:Gen
Start Index:3
End Index:7
Line Number:14
Last Index in Line:326
Line Length:331
Text: REB
Book:Gen
Start Index:7
End Index:110
Line Number:14
Last Index in Line:326
Line Length:331
Text: Genesis 1.6     God said, �Let there be a vault between the waters, to separate water from water.� 1.7 REBThe text file looks like this.
My problem is what happend to 1.5 in the output? It's like it got skipped some how.
Revised English Bible
Revised English Bible
Old Testament
Law
Genesis
Copyright � 1989 by Oxford University Press and Cambridge University Press.
Used by permission.
GENESIS
1.1     The creation of the universe
The creation of the universe
REB Genesis 1.1
1.1 �1�REB Genesis 1.1�IN the beginning God created the heavens and the earth.1:1�2 In . . . earth was: or When God began to create the heavens and the earth, 2the earth was.���1.2 REB Genesis 1.2�The earth was a vast waste, darkness covered the deep, and the spirit of God hovered over the surface of the water.1:2 the spirit . . . hovered: or a great wind swept; or a wind from God swept.���1.3 REB Genesis 1.3�God said, �Let there be light,� and there was light; 1.4 REB Genesis 1.4�and God saw the light was good, and he separated light from darkness. 1.5 REB Genesis 1.5�He called the light day, and the darkness night. So evening came, and morning came; it was the first day.
REB Genesis 1.6
1.6 REB Genesis 1.6     God said, �Let there be a vault between the waters, to separate water from water.� 1.7 REB Genesis 1.7�So God made the vault, and separated the water under the vault from the water above it, and so it was;

You are also missing 1.7
"So God made the vault, and separated the water under the vault from the water above it, and so it was;"
What happens is that the line
while(mat.find()) {
steps down the line looking for the pattern "REB". But you are always taking the line upto the last match of "REB". Note that the output lines always end in "REB".
Text: Genesis 1.4�and God saw the light was good, and he separated light from darkness. 1.5 REB
So after you match this "REB" and print out the text up to it there are no more "REB" s on the line to
match so you drop out if the while loop without processing the end of the line.
A quick way to check this is to add "REB" at the end of the line and see if it picks it up.

Similar Messages

  • Part of my scren isblack and grey whats gone wrong please help

    part of my screen is black and grey whats gone wrong ? Please Help

    What to Do When Your iPad Won't Turn On
    http://ipad.about.com/od/iPad_Troubleshooting/ss/What-To-Do-When-Your-Ipad-Wo-No t-Turn-On.htm
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    iPad Frozen? How to Force Quit an App, Reset or Restart Your iPad
    http://ipadacademy.com/2010/11/ipad-frozen-how-to-force-quit-an-app-reset-or-res tart-your-ipad
    iPad: Basic troubleshooting
    http://support.apple.com/kb/TS3274
     Cheers, Tom

  • IPhone 3Gs started vibarting and died, what is wrong?

    my 3Gs started vibrating and than died, what is wrong?

    Hopefully a one-time glitch. Reset, hold both home and power buttons until the iPhone begins to start. Usually takes about 10 seconds of holding both buttons. If still nothing, connect to Wall Charger for 10 minutes. If still OFF, Reset while on charger, it may take about 20 seconds of holding both buttons while on charger. If you decide your iPhone is not working perfect, you can Restore the Firmware with iTunes on computer. If still problems and you have Warranty or AppleCare make Genius Reservation and take to Apple for resolution.

  • Nano 6th turns on for a few seconds then screen goes black and nothing. what is wrong with it....

    My 6th gen nano turns on for a few seconds, then screen goes black and nano goes off. what is wrong with it? can any one help me out? do I need new battery? do I need a full repair? or is there something I can do myself to fix it.  Thanks for your help. 

    At the moment I say as I've fixed, momentarily:
    I made a downgrade to 1.0
    The problem, gentlemen, is the upgrade from 1.1 and 1.2
    It is a pity that I lost all the new features offered by the new firmware , just because Apple staff could not think to try this new update, on ipods with some airtime.
    I hope Apple pull out a version 1.3 with the ability to choose the feature detection, and the user can disable it at will.

  • HT201407 I used the correct password and email what's wrong ?

    When I wrote the Apple ID and pass it said "khaled*******@gmail.com " could not be used to unlock this iPhone . What's wrong?

    We don't mean to cause concern, Rosie511. The status will reflect "Not Received" until your device has been inspected and processed. Afterwards, you will receive an email updating you of the status of your Trade-in. Should you have any questions about your Trade-in you can send an email by using the "Contact Us" tab: http://bit.ly/GGnDDC
    AndreaS_VZW
    Follow us on Twitter @VZWSupport

  • My MacBook keeps freezing and crashing during startup and use, what's wrong?

    My MacBook functioned perfectly for YEARS, and suddenly it started freezing during startup. One of four things happens: it starts up no problem, it freezes at the apple logo with the load wheel spinning, it freezes at a 'no' symbol (a circle with a line through it) with the load wheel spinning, or it freezes at a logo which is a folder with a question mark in it. It occasionally goes through and gets to the homepage, where I can use the computer for a certain amount of time before it freezes again. I never get to use it for more than 30 or 45 minutes at a time.
    Yes, I have updated all my software, and I haven't dropped it or downloaded anything that could cause this issue. What could be going wrong? :(

    There are corrupted system files involved, so my suggestion is to reinstall OS X.
    If you are using Snow Leopard:
    Reinstall OS X without erasing the drive
    Do the following:
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install the Combo Updater for the version you prefer from support.apple.com/downloads/.
    If you are using Leopard or Tiger:
    How to Perform an Archive and Install
    An Archive and Install will NOT erase your hard drive, but you must have sufficient free space for a second OS X installation which could be from 3-9 GBs depending upon the version of OS X and selected installation options. The free space requirement is over and above normal free space requirements which should be at least 6-10 GBs. Read all the linked references carefully before proceeding.
    1. Be sure to use Disk Utility first to repair the disk before performing the Archive and Install.
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard or Snow Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Do not proceed with an Archive and Install if DU reports errors it cannot fix. In that case use Disk Warrior and/or TechTool Pro to repair the hard drive. If neither can repair the drive, then you will have to erase the drive and reinstall from scratch.
    3. Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When you reach the screen to select a destination drive click once on the destination drive then click on the Option button. Select the Archive and Install option. You have an option to preserve users and network preferences. Only select this option if you are sure you have no corrupted files in your user accounts. Otherwise leave this option unchecked. Click on the OK button and continue with the OS X Installation.
    4. Upon completion of the Archive and Install you will have a Previous System Folder in the root directory. You should retain the PSF until you are sure you do not need to manually transfer any items from the PSF to your newly installed system.
    5. After moving any items you want to keep from the PSF you should delete it. You can back it up if you prefer, but you must delete it from the hard drive.
    6. You can now download a Combo Updater directly from Apple's download site to update your new system to the desired version as well as install any security or other updates. You can also do this using Software Update.

  • Transaction Launcher and Parameters - what is wrong?

    Hi guru
    my issue: in our CRM webui we need to invoke an ECC custom transaction and fill a field with a dynamic value (opportunity id).
    So to understand better I started with transaction launcher wizard to invoke the tx VA01 and I'm able to see in the webui the transaction.
    Some parameters of the wizard are:
    ID: ZERP_TX_VA01
    COMPONENT SET: ALL
    CLASS NAME: ZCL_ERP_TX_VA01
    STATEFUL: EMPTY
    RAISE VETO: X
    OBJECT TYPE: EMPTY
    OBJECT ACTION: EMPTY
    TRANSACTION TYPE: BOR
    LOGICAL SYSTEM: ECC
    BOR OBJECT: ZTSTC
    METHOD NAME: EXECUTE
    ICWEBCLIENTBORKEYPARAMETER Object Key: VA01
    PARAMETER: EMPTY
    Now if we want to fill the AUART (AAT id parameter) with a value 'Z001' what can we do?
    I followed several post and blog so the solution that I applied is:
    in the "execute" method of ZTST object I created a new parameter called "AAT" table VBAK and field AUART. In the prepare_data_flow of the class I setted the container data where the iv_name is "AAT" an iv_value is "Z001". Now when I invoke via CRM UI the transaction I see that the AAT field is always empty. Can you help me?
    Roberto

    Plz check this wiki entry.
    http://wiki.sdn.sap.com/wiki/display/CRM/CRMWebUI-LaunchingtransactionsinGUIforWindows
    Rg,
    Harshit

  • Assessing debug, and finding what's wrong...

    What would be a better and proper way to find bugs in Instruments? I never can seem to figure it out.

    You are right assuming that I actually wanted e.printStackTrace After replacing, I got ClassNotFoundExceptions. They vanished after substituting
    Class c = Class.forName(classes); with
    Class c = Class.forName("Inner$" + classes);
    Now I'm getting InstantiationExceptions... I didn't succeed in adapting the solution offered posted here:
    http://forum.java.sun.com/thread.jsp?forum=4&thread=198085
    since the Inner class is hard coded...

  • Seek and flvPlayback - what's wrong with this please?

    Hi,
    I'm trying to build a player where there's a button that pause the video and then moves the video forward by one second. I am using the following:
    flvPlayback.pause();           
    var newTime = flvPlayback.playheadTime + 1;          
    var currentTime = timeToString(newTime);           
    var endTime = timeToString(flvPlayback.totalTime);         
    progressLabel.text =  currentTime + " / " + endTime;           
    percentLabel.text = Math.round(currentTime/endTime) + "%";           
    flvPlayback.seek(newTime);
    This works for the progressLabel and percentLabel but the video itself does not move to the specified point. Only when I hit play does the video scrub to the right point - can someone help please?

    Thanks for that - but is there anyway to have the player paused instead of playing automatically?
    I tried to use this (where pausePlayback is just a flvPlayback.pause function) but it didn't work:
                flvPlayback.pause();
                var newTime = flvPlayback.playheadTime + 1;
                var currentTime = timeToString(newTime);
                var endTime = timeToString(flvPlayback.totalTime);
                progressLabel.text =  currentTime + " / " + endTime; percentLabel.text = Math.round(currentTime/endTime) + "%";
                flvPlayback.seek(newTime);
                var timer:Timer = new Timer(40, 1);
                timer.addEventListener(TimerEvent.TIMER_COMPLETE, pausePlayback);
                timer.start();
                flvPlayback.play();

  • My Ipod camera is frozen the shutters dont open and i did everything i could restart, restored, and updated. what is wrong?

    ?

    It is very likely broken.  I would make an appointment at the Genius Bar of an Apple store or call AppleCare

  • ITunes and Audiobooks: What's wrong with that pair?  Help!!!!!!!!!!!!!!

    Hey,
    Every audiobook CD ends up in the music folder. I thought that the whole idea of having separate folders was to keep things organized. If it would only work like it's suppose to!!!!!!!!
    Can anyone tell that I'm a little frustrated here?

    http://aldoblog.com/audiobooks/

  • Can someone please tell me what's wrong with the Inside of my iPad Charger? *Picture Included

    It won't charge my iPad. So I wanted to take a good look inside and see what's wrong with it. But I don't know anything about these wires. Here's the Pic of it.
    http://oi39.tinypic.com/2ed5yl2.jpg
    http://oi42.tinypic.com/5btptt.jpg
    http://oi39.tinypic.com/ih8rq1.jpg
    PLEASE HELP. It would be a Big Help

    That's unfortunate, because it would appear that the cable is pretty much toast. If it wasn't before, it pretty much is now that you've cracked it open.
    Either borrow one, or bite the bullet and buy one locally. You're not getting anywhere with that one.

  • Even my iPod doesn't know what's wrong with it.

    I have a 4th Gen iPod that just stopped working a few months ago. I have checked the iPod support pages, but I have the apparently unique problem of getting pretty much every error message that you can get. The Sad iPod, the Folder and exclamation mark, the low battery symbol, and sometimes the Apple apple for a few seconds before it turns off.
    It doesn't seem like it's a battery issue, since it was working fine one day and then just stopped starting up the next. It might be, though, I simply don't know. I've been pretty much resigned to the probability that my iPod is broken forever, but I really miss it.
    Has anyone experienced anything similar to this and know what is wrong? I highly doubt that several problems just started over the course of one night, but I get all the error messages. My iPod isn't covered under warranty any more, so if there is some way to get it fixed, knowing the cost for fixing whatever is wrong would be helpful as well.
    Thanks.

    I'm assuming you tried to restore/update it.
    It sounds like either a nasty hardware issue or you could have corrupted files on your iPod.
    When all else fails, get a refurb from apple.
    Their cheaper and just as good.

  • I am trying to print a color photo on my MacBook Pro from iPhoto (not using Photoshop) using Epson 2200 printer, and everything I do in the Color Matching and Print Settings results in a photo with a pink cast to it. What am I doing wrong?

    I am trying to print a color photo on my MacBook Pro from iPhoto (not using Photoshop) using Epson 2200 printer, and everything I do in the Color Matching and Print Settings results in a photo with a pink cast to it. What am I doing wrong?

    Have you checked the ink cartridges and made sure the nozzles are clear? Are you able to print from outside of iPhoto with the correct color?
    Try the following: make temporary copy of the library and do 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. 
    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.
    OT

  • What is wrong with my shipping address? I want to order pictures via apple store with iPhoto. Apple Id and payment seem ok. My current and correct shipping address appears with red letters. Why and what to do?

    What is wrong with my shipping address? I want to order pictures via apple store with iPhoto. Apple Id and payment seem ok. My current and correct shipping address appears with red letters. Why and what to do?
    Maybe this is relevant: I bought iphoto from the German apple store but I now live in Italy. I have tried German credit card with German invoicing address and Italian shipping address. And I have tried Italian credit card with Italian invoicing address and Italian shipping address. The phenomenon is the same: shipping address appears in red and I am asked to fill in the mandatory fields (which turn red whatever I enter).

    KarinavD,
    what is the setting for the Print Products Store in the Advanced Tab of the iPhoto Preferences?
    The country you select there has to match the billing address. And your billing address should match the country of your AppleID and credit card used with the AppleID.
    Regards
    Léonie

Maybe you are looking for