Problem with regular exp.

i'm trying to write a program that prints
lines from a string:
Pattern p = Pattern.compile("^(.*)$", Pattern.MULTILINE);
String s = "firstline\rsecondline\r";
Matcher m = p.matcher(s);
while (m.find()) {
System.out.println("line: " + m.group());
System.out.println("start: " + m.start());
System.out.println("end: " + m.end());
The problem is that i get an IndexOutOfBounds
exception, thrown by m.find(). Seems like a bug
to me. Or have i done something wrong?
It doesn't happen if the string ends with '\n' or '\r\n'.

It's a bug. Would you like to report it, or shall I? Whoever reports it, should do so quickly, if we want it to be fixed in Tiger. In the meantime, you can use the following as a workaround:Pattern p = Pattern.compile("(?<!.)(.*)$", Pattern.MULTILINE);

Similar Messages

  • Problems with regular Texting since iOS 7.0.3

    Hello, I have an iPhone 5s recently upgraded to iOS 7.0.3 via OTA update. I never use iMessage, I have an unlimited text plan, so I always have used SMS with everyone. However, after this last update, I have problems with regular SMS. I can send SMS to everyone as usual, but can only get text messages from some-all of them using iPhone 5 with at least the lastest iOS6 version. I have noticed then only way to text them now is to turn on iMessage, otherwise I keep missing their replies. These are people, that until the last upgrade, I was texting with on a regular basis with no problems using plain SMS with iMessage option OFF. Contrary to most, I don't want to use iMessage but rather use regular carrier provided SMS.
    For instance, both my son and daughter use an iPhone 5 with iOS 7 (but not the latest patch 7.0.3) installed, I can text with my son OK, but can't get any texts from my daughter, can only communicate with her using iMessage-BTW, we are all on the same network on a family plan. Can't understand this at all. Since I can SMS with some, but not others I don't think this is a problem with my carrier but rather a problem with my phone since the update to 7.0.3, and they say I am the only one they have problem with texting with and I am the only one on the new software version.
    Anyone else has noticed this issue.

    I wonder if this may have something to do with iMessage on my Macs. Recently updated to Maverirks and the iMessage app on my Macs was set up to my email and mobile phone (it wasn't before). I wonder if this is so, then whoever I send an SMS to that has iMessage on and replies back, will be picked up by iMessage since is turned on on my Mac, since replies go to the Mac but not my phone. If the sender has iMessage off, I get the SMS fine.

  • Problem with utility exp

    I have a problem with utility exp, and crash my database
    error ORA-0600 ORA-04031

    I have a problem with utility exp, and crash my database
    error ORA-0600 ORA-04031

  • Problem with Regular Expression

    Hi There!!
    I have a problem with regular expression. I want to validate that one word and second word are same. For that I have written a regex
    Pattern p=Pattern.compile("([a-z][a-zA-Z]*)\\s\1");
    Matcher m=p.matcher("nikhil nikhil");
    boolean t=m.matches();
    if (t)
              System.out.println("There is a match");
         else
              System.out.println("There is no match");
    The result I am getting is always "There is no match
    Your timely help will be much appreciated.
    Regards

    Ram wrote:
    ErasP wrote:
    You are missing a backward slash in the regex
    Pattern p = Pattern.compile("([a-z][a-zA-Z]*)\\s\\1");
    But this will fail in this case.
    Matcher m = p.matcher("Nikhil Nikhil");It is the reason for that *[a-z]*.The OP had [a-z][a-zA-Z]* in his code, so presumably he know what that means and wants that String not to match.

  • Problem with Regular Expression: XML comment parsing

    I have create pattern to parse xml comments:
    <!--(?!.*(<!--)).*-->It works fine but only problem that I have is that it parse only last occurrence :(

    sabre150 wrote:
    MrJbee wrote:
    I have create pattern to parse xml comments:
    <!--(?!.*(<!--)).*-->It works fineI'm surprised it works fine since the ".*" is greedy and will gobble as much as it can and you will end up matching from the start of the first comment to the end of the last comment.
    but only problem that I have is that it parse only last occurrence :(Make the ".*" reluctant using ".*?" or, best of all, use an XML parser.
    Edited by: sabre150 on Jan 11, 2010 4:00 PMFirst at thanks for reply.
    Second it is not so greedy like it look. Because of that:
    (?!.*(<!--))I can`t use xml parser since It is only part of my JEditor with styles. I use reg exp to highlight comments, strings, chars and so on....
    By the way I try to replace .* => .*? and it is still no results. I mean only last is selected. Maybe you have an example on how to match structure if the do not
    have specified substrings.
    Something like this:
    hello[^(guten tag)]*bye // I know that this is wrongEdited by: MrJbee on Jan 11, 2010 1:22 PM

  • Problems with regular expressions.

    Hi all.
    I want to substitute within an xml file a string with the following structure:
    Referencer="//@Model/@OwnedElement.0/@OwnedElement.1/@OwnedElement.0/@OwnedElement.1/@OwnedElement.33 ..."
    where the dots mean that the string within the quotes may be repeated (separated by spaces) many times.
    I've tried to match such expression with java regex, with no luck. I thought running
    line.contains("Referencer=\"[^\"\\r\\n]*\"");
    would return true, but it didn't.
    Could anybody point me the right way?.
    Thank you all in advance.

    Method String.contains() does not take a regular expression - you need to use method String.matches() or class Pattern.
    This looks to be a good problem to solve using http://elliotth.blogspot.com/2004/07/java-implementation-of-rubys-gsub.html .

  • Problem with Regular Expressions

    Hi Everyone:
    I'm having a problem finding the easiest way to retrieve the replacement text that has been edited to insert back-references from previous matches. For instance,
    Lets say I want to use the below regular expression
    foo_bar([1-9])_fun
    on the search text
    foo_bar1_fun
    foo_bar2_fun
    foo_bar3_fun
    and then the replacement text would be
    foobar_fun$1
    so in the end I would get
    foobar_fun1
    foobar_fun2
    foobar_fun3
    What I would like to do is be able to extract the replacement text that has been modified with the back reference matches after I use the Matcher.appendReplacement(stringbuffer, string) method.
    So to clarify further, after I find the first match and use the appendReplacement Method, I would like to extract just the replacement that was made to the text, in this case foobar_fun1
    Thanks for any help!

    Alright, thanks for the reply. I'll try and make this a little more clear
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class LeClassName {
       public static void main(String[] args) {
          String input = "12341234foo_bar1_fun24342345foo_bar2_fun3522545foo_bar3_fun3423432";
          Pattern pattern = Pattern.compile("foo_bar([1-9])_fun");
          StringBuffer sb = new StringBuffer();
          Matcher matcher = pattern.matcher(input);
          while (matcher.find()) {
             matcher.appendReplacement(sb, "foobar_fun$1");
             //after the first pass through, I would like to extract, foobar_fun1
             // but what is in sb is 12341234foobar_fun1
          System.out.println(sb.toString());
    }I did find a solution myself after a bit of thinking but if anyone can come up with a better solution do tell and I'll award that person the answer. Thanks again!
    My Solution:
    private String fixBackReplacements() throws IndexOutOfBoundsException {
                String currentMatch = this.findMatch.group();
                Pattern temporaryPattern = Pattern.compile(findText);
                Matcher temporaryMatcher = temporaryPattern.matcher(currentMatch);
                return temporaryMatcher.replaceFirst(replaceText);
    }

  • Problems with regular GSM reception?

    Hi, I've had poor reception since I bought the iPhone 3G at the end of July. After updating to 2.0.2, what was poor reception has become terrible reception, but I am not just having problems on 3G networks. I know others have had the experience that when they turn off 3G, they still get good reception on EDGE, but this has not been my experience at all. Prior to getting the iPhone, I had a Motorola RAZR on AT&T that got between 3 to 4 bars of reception on a regular 850 MHz GSM band at my house (I know it was using this band because I live in a cell dead-spot and purchased a $250 dollar Wi-Ex YX500-CEL cellular repeater which operates on the 850 MHz band and cured my cell phone reception problems at my house), and I had no problems making or receiving calls. Since upgrading to the iPhone 3G, at home I get 1 bar of GPRS switching to 1 bar EDGE or 1 bar GSM or No Service. Usually it sits at 1 bar, and after I try to make a call, it usually says call failed and No Service. I've been on the phone with Apple and AT&T, done multiple resets and restores to no avail. The Apple rep blamed AT&T service and the AT&T rep blamed Apple hardware. At the time, I was thinking "if the iPhone is quad band, why isn't it using the cell band from my repeater which works great with my RAZR and also works great for my roommate's Verizon phone?" I had been thinking that for some reason, the iPhone was not switching to use the band from my repeater, and was instead trying to use a very weak EDGE signal or something. I think the answer is, the iPhone must have poor reception on other bands, not just 3G, because last night I discovered if I walk right up to my cell repeater, within 3 feet or less, my iPhone magically has a full 5 bars of service (not 3G, not EDGE and not GPRS). As soon as I walk outside the 3 feet radius from my repeater, the signal starts to dramatcially drop off so that by the time I am about 8-10 feet away, it is back to 1 bar vs No Service. So, now I am thinking the iPhone just has generally crappy reception for other bands as well, not just 3G. I don't think it's just a defect with my particular phone, because at work, I actually get full 4-5 bars of 3G reception, and my phone works great in that particular location. What do you all think?

    I wonder if this may have something to do with iMessage on my Macs. Recently updated to Maverirks and the iMessage app on my Macs was set up to my email and mobile phone (it wasn't before). I wonder if this is so, then whoever I send an SMS to that has iMessage on and replies back, will be picked up by iMessage since is turned on on my Mac, since replies go to the Mac but not my phone. If the sender has iMessage off, I get the SMS fine.

  • Problem with regular crash with Xorg and nvidia

    Hello!
    I am using a archlinux distribution for about 5 years. There was sometime problems but now it is very unstable. Every reboot I have a crash of Xorgs and with this a crash of system. Log:
    Backtrace:
    0: /usr/bin/Xorg (xorg_backtrace+0x3b) [0x809bdab]
    1: /usr/bin/Xorg (0x8048000+0x520f5) [0x809a0f5]
    2: (vdso) (__kernel_rt_sigreturn+0x0) [0xb78d840c]
    3: /usr/bin/Xorg (0x8048000+0x272a0) [0x806f2a0]
    4: /usr/bin/Xorg (0x8048000+0x1a685) [0x8062685]
    5: /lib/libc.so.6 (__libc_start_main+0xe6) [0xb750db86]
    6: /usr/bin/Xorg (0x8048000+0x1a271) [0x8062271]
    Fatal server error:
    Caught signal 3 (Quit). Server aborting
    About 1 month ago it looks like restart of Xorgs when I press enter key. Alway ENTER key. After some updates/nvidia driver combinations - doesn't change anything. Now after fresh reinstall (well crashes destroys my ext3 filesystem an I need to reinstal the root file system) there are crashes, but now, every freeze I have to restart system. Now I am switchingo into ubuntu, I will try to check sometimes if something changed.
    Cashes repeats every reboot from... maby 3-4 months. Now I can say my system is not stable, I use this in work - so this situation is really bad.
    My configuration:
    [mik@mik-l ~]$ lspci
    00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub (rev 03)
    00:01.0 PCI bridge: Intel Corporation Mobile PM965/GM965/GL960 PCI Express Root Port (rev 03)
    00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 03)
    00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 03)
    00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 03)
    00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 03)
    00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 03)
    00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 03)
    00:1c.2 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 3 (rev 03)
    00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 03)
    00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 03)
    00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 03)
    00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 03)
    00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f3)
    00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller (rev 03)
    00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller (rev 03)
    00:1f.2 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA IDE Controller (rev 03)
    00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 03)
    01:00.0 VGA compatible controller: nVidia Corporation G86 [GeForce 8600M GS] (rev a1)
    04:00.0 Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61)
    06:01.0 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 IEEE 1394 Controller (rev 05)
    06:01.1 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 22)
    06:01.2 System peripheral: Ricoh Co Ltd R5C843 MMC Host Controller (rev 12)
    06:01.3 System peripheral: Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter (rev 12)
    06:01.4 System peripheral: Ricoh Co Ltd xD-Picture Card Controller (rev ff)
    06:07.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)
    I am using compiz and emerald.
    greetes
    AleExtra
    Sorry for my poor english - I always read documentation, not writing this.

    well, after some time, the crach come back. In work I have fully updated system, in home, I wont update system, because of this problem.
    On random (I think) enter it crached:
    (II) XINPUT: Adding extended input device "Power Button" (type: KEYBOARD)
    (**) Option "xkb_rules" "evdev"
    (**) Option "xkb_model" "evdev"
    (**) Option "xkb_layout" "us"
    Backtrace:
    0: /usr/bin/Xorg (xorg_backtrace+0x3b) [0x809f81b]
    1: /usr/bin/Xorg (0x8048000+0x54745) [0x809c745]
    2: (vdso) (__kernel_rt_sigreturn+0x0) [0xb787240c]
    3: /usr/bin/Xorg (0x8048000+0x40170) [0x8088170]
    4: /usr/bin/Xorg (0x8048000+0x1a705) [0x8062705]
    5: /lib/libc.so.6 (__libc_start_main+0xe6) [0xb7466c76]
    6: /usr/bin/Xorg (0x8048000+0x1a2f1) [0x80622f1]
    Fatal server error:
    Caught signal 3 (Quit). Server aborting
    Please consult the The X.Org Foundation support
    at http://wiki.x.org
    for help.
    Please also check the log file at "/var/log/Xorg.0.log" for additional information.
    (II) Macintosh mouse button emulation: Close
    (II) UnloadModule: "evdev"
    (II) BTC USB Multimedia Keyboard: Close
    (II) UnloadModule: "evdev"
    (II) BTC USB Multimedia Keyboard: Close
    (II) UnloadModule: "evdev"
    (II) Logitech USB Optical Mouse: Close
    (II) UnloadModule: "evdev"
    (II) Power Button: Close
    (II) UnloadModule: "evdev"
    (II) Power Button: Close
    (II) UnloadModule: "evdev"
    and restart Xorg

  • Problem With Imp/Exp

    I have exported a database schema containing spatial data using exp and Imported it into a new database using imp. It seems to be dropping rows from the user_sdo_geom_metadata table in the new database.
    Has anyone else seen this problem and is there a solution to the problem?

    Oracle Spatial will only carry rows from the user_sdo_geom_metadata view for tables that have spatial indexes. You could choose to export the contents of the view by doing something like this:
    create table my_sdo_geom_metadata as select * from user_sdo_geom_metadata;Export the my_sdo_geom_metadata table, then after the import
    insert into user_sdo_geom_metadata
      (select *
       from my_sdo_geom_metadata
       where table_name not in
          (select table_name from user_sdo_geom_metadata);

  • Problem with  regular expression  validation

    hi,
       how can i validate folder structure
       conditions
         no two  forward slashes(/) in a sequence no  special characters
        " /w" and   "  '/'  "    
       e:/tomcat/ss/ss.text
           if(valStr.matches("((['/'])[a-zA-Z0-9_]*)")){
                    System.out.println("matches");   
             else
                    System.out.println("notmatches");
    this is no correct .
    please give me right solution       
    with regards
    ss

    hI,
      /appmg/dd/
    is  the paths for solaris( starts with /)
    i have to test  if it is valid path name or not
    with regards
    ss

  • VHS to DV tapes...problem with new  Sony camcorders

    I had a nice Sony miniDV camcorder, the DCR HC 30. Worked great to record almost all of my VHS tapes to DV, which I am using to created my iMovies. The camcorder worked fine in this mode. It then had a problem with regular recording, capturing the audio, but not video. Known problem to Sony, who repaired the camcorder at no cost. It worked great again, but the last time I went to record from my VHS tape, it worked for an hour, and then the touch-screen menu failed to respond to touch. (Another story).
    I also have a newer Sony camcorder, the DCR HC 26. Connected it to the VCR to record from the VHS tape. I then discovered that this camcorder will allow recording FROM the camcorder TO the VCR with the AV connector, but if I want to record FROM the VCR, it will only work using the DV connector into an iLink port (Firewire).
    I went to the 'Sony Style' store (yes,Palo Alto has everything!) and the guy first insisted it could be done with the new HC 38 and 48, but after he actually read the manuals, it was the same as the HC26: must have a Firewire port on the VCR. How dumb is that? How many of us have all these old VHS tapes, probably old VCRs too, and none of the old ones will have FireWire ports!
    I have always recommended copying VHS footage to DV tapes, and now I am not going to be able to do that unless I get a converter. Seems a bit expensive for just the few VHS tapes that I forgot to convert previously.
    I tried to see if the HC 30 can be repaired again....Sony wants $211 just to check it out. I can buy a new camcorder for $320 so it doesn't seem worth it unless I can connect the touch-screen failure with the problem with video recording that was supposedly corrected.
    May have to get a converter.....last resort is another old camcorder Sony TRV something. It is on its last legs, but maybe it could work for a few hours more!
    Wanted to let it be known that direct recording from an old VCR to new Sony miniDV cannot be done.

    Hi tilman - yes - bottom line is not to discard an old vidcam with analogue-in when buying its 'higher-speced(?!) replacement - although that doesn't help Beverly with her problem.
    There must be large numbers of second-hand cams with that function being sold as people rush to buy DVD vidcams etc, so it will be worth looking out for a good cheap one.
    It seems that soon the only mini-DV cams will be higher-end models, some of which, being larger, have much reduced portability. Ah! Progress!

  • Blu-ray problems with GT70 Dragon 2202 edition

    I've had the laptop for a couple of months now and things seemed ok. I would say in the last couple of weeks I've noticed an increasing number of blu-ray discs that the drive has a problem with reading... it's really slow to 'explore' them. I have powerDVD v13 and that will tell me the bluray is corrupted when trying to open it. I have absolutely no problems with regular DVDs, just blu-rays seem to have a problem.
    I found on the MSI support site a tool to upgrade the DVD to a newer firmware version for what seems to be this very problem but that didn't help.
    I'm just concerned that this seem to get progressively worse over the last couple of weeks vs always being like this.
    Any thoughts ?

    After talking to tech support (only option they suggested was doing a full system restore - which didn't help) I submitted for RMA on the 1st. Hopefully they will put another brand of bluray in. Doing some google searches on the TSS model it shipped with shows many complaints about either the drive not reading DVDs or Blurays after some time.

  • HT1694 I'm having a lot of problems with the hotmail account, regularly is indicating an error in the server, that I have to introduce the password again that late that this is wrong. I have changed the password making this shorter but it does not work.

    I'm having a lot of problems with the hotmail account, regularly is indicating an error in the server, that I have to introduce the password again that late that this is wrong. I have changed the password making this shorter but it does not work.

    bump? Is bumping allowed? Lol.
    I just really need some help here.

  • .EXP problem with  library .JAR

    Hello,
    I would like to create a javacard library to import it in a new project. Unfortunately I have a problem when I import my library and build in the new project. This is my process:
    1) To create my library I generate a .JAR with my .class files
    2) Seconde step I generate an .EXP file with interface desciption.
    3) in my new project I import my library and I put .EXP file in 'export' directory
    4) I use my library in new servlet
    BUT when I build my new project, i have errors with my .EXP file. Errors are:
    class com.sdk.StringUICC not found in export file sdk.exp.So i have used exp2file to read my .EXP file and this .EXP doesn't decribe all my classes but just my package:
    export file {          // com/sdk
         magic     00FACADE           // in hex
         minor_version     1
         major_version     2
         constant_pool_count     2
         constant_pool {
              Constant_Utf8_info {
                   tag     1
                   length     22
                   bytes     com/sdk
              CONSTANT_Package_info {
                   tag     13
                   flags     0
                   name_index     0          // com/sdk
                   minor_version     0
                   major_version     1
                   aid_length     12
                   aid     0xA0:0x0:0x0:0x0:0x18:0x52:0x1:0x4:0x0:0xFB:0x0:0x41
         this_package     1
         export_class_count     0
         export_classes {
    }So my question is : "What I have to do to generate a correct .EXP file?"
    Thank you :)
    Jérémie

    I didn't use converter command correctly :) it's all right now
    Best regards
    Jérémie

Maybe you are looking for

  • Shouldn't I be able to get higher speeds?

    I'm on the 1.5 to 3.0 tier, the CO is 2 miles away by car, and my modem stats are: Transceiver Revision 3.3.6.10.0.1 Vendor ID Code 4D54 Line Mode ADSL_G.dmt Data Path INTERLEAVED Transceiver Information -- Down / Up DSL Speed (Kbits/Sec) --- 1504 /

  • MIME Version in Mail Adapter

    Hi, I'm trying to figure out what version of MIME XI uses when I send an htmlb email. I'm also wondering if I can change the MIME version. Here is the XI payload xml file generated: <?xml version="1.0" encoding="UTF-8"?> <ns:Mail xmlns:ns="http://sap

  • Radeon 9000 agp on my G4

    so, finally my Ati Radeon 9000 64mb arrived from USA (very quickly... only 10 days!!). it has both adc and dvi connector; of course I'll use DVI port. so the question is: can I use a DVI to VGA adapter? (my lcd has both of them but DVI is used by PC)

  • Can i use forms 9i for client server applicaitons

    Hi, I have to build a client/server application.Right now, we are using oracle 9i and developer suite 10g. In one of the articles on OTN, it says that from forms 9i onwards, it's not supporting client/server model. Do i have to use 6i for this. Thank

  • Where do I get OS 9 classic???

    This may sound a bit stupid or even helpless, but I've been searching all over the applesite to find a place to download OS 9 classic with no luck so far. Please, oh please help me, as I'm longing to play Diablo on my ibook!!