Is it possible I found a bug in Java Pattern (JDK 1.5)???

It is hard to believe that I should have found an error in the java.util.regex.Pattern class - and I hope you can tell me I'm wrong. Look at this example:
Let's say the pattern is "%\d+". I can then easily match against, let's say "%20". If I however changes the string to "%20 ", then no match, not complete or partial! The oddest thing is that it seems to be connected to the usage of "%". To really nail the point..if you change the string to "%20 %20 ", then you will find two partial matches (which is correct). I have tried to debug the Pattern-class myself - but my debugger wouldn't show me the local variables in the Pattern class, so I gave up. Try to run the program below with JRE 1.5 (update 18) and exchange the "s" var to test it.
public class RegExp {
private static Pattern pattern = Pattern.compile("%\\d+");
public static void main(String[] args) {
          String s = "%20";
          Matcher m = pattern.matcher(s);
          if (m.matches()) {
               System.out.println("Complete match:");
               for (int i = 0; i <= m.groupCount(); i++) {
                    System.out.println("Group " + i + " : " + m.group(i));
          } else if (m.find()) {
               int pos = 0;
               while (m.find(pos)) {
                    System.out.println("Partial match:");
                    pos = m.end();
                    for (int i = 0; i <= m.groupCount(); i++) {
                         System.out.println("Group " + i + " : " + m.group(i));
          } else {
               System.out.println("NO MATCH");
Edited by: mortensi on Jun 4, 2009 2:25 AM

Sorry about the code. It truly compiled and worked..but I didn't know about the code-tag thing. Here is an version that should work well...or at least I hope so
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegExp {
     private static Pattern pattern = Pattern.compile("%\\d+");
      * @param args
     public static void main(String[] args) {
          String s = "%20";
          Matcher m = pattern.matcher(s);
          if (m.matches()) {
               System.out.println("Complete match:");
               for (int i = 0; i <= m.groupCount(); i++) {
                    System.out.println("Group " + i + " : " + m.group(i));
          } else if (m.find()) {
               int pos = 0;
               while (m.find(pos)) {
                    System.out.println("Partial match:");
                    pos = m.end();
                    for (int i = 0; i <= m.groupCount(); i++) {
                         System.out.println("Group " + i + " : " + m.group(i));
          } else {
               System.out.println("NO MATCH");
}

Similar Messages

  • It's possible change WSAD 5.1.2 java version[jdk 1.4.1],i woudl jre 5.0??

    hi
    i have a big problem,i would use tiger'jre but isn't possible,because also i change in Window->Preferences->Java-> Installed JREs in jdk 1.5,
    when i start the server(i use for jsf) ,this is report:
    ************ Start Display Current Environment ************
    WebSphere Platform 5.1 [BASE 5.1.0.3 cf30412.02] [JDK 1.4.1 b0344.02] running with process name localhost\localhost\server1 and process id 2320
    Host Operating System is Windows XP, version 5.1
    Java version = J2RE 1.4.1 IBM Windows 32 build cn1411-20031011 (JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM
    was.install.root = d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51
    user.install.root = d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51
    Java Home = d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre
    ws.ext.dirs = d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/java/lib;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/classes;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/classes;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/lib;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/lib/ext;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/web/help;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime;H:\Documents and Settings\Administrator\Desktop\sorgenti JDavide\repository5\progetti\JDAvide\driverDB\sapdbc.jar;H:\Documents and Settings\Administrator\Desktop\sorgenti JDavide\JVolaSms-20040413.jar;H:/Programmi/IBM/SQLLIB/java/db2java.zip;d:/Programmi/IBM/WebSphere Studio/Application Developer/v5.1.2/wstools/eclipse/plugins/com.ibm.etools.webservice_5.1.2.3/runtime/worf.jar
    Classpath = d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/properties;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/properties;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/lib/bootstrap.jar;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/lib/j2ee.jar;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/lib/lmproxy.jar;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/lib/urlprotocols.jar;d:/Programmi/IBM/WebSphere Studio/Application Developer/v5.1.2/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.1.1.1/runtime/wteServers.jar;d:/Programmi/IBM/WebSphere Studio/Application Developer/v5.1.2/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.1.1.1/runtime/wasToolsCommon.jar
    Java Library path = E:\Programmi\Java\jre1.5.0_03;d:\Programmi\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51/bin
    ************* End Display Current Environment *************
    i need to use jdk 1.5 for example for new method(1.4.02) of string (ex "".replaceFirst),etc,etc.
    i hope in your.
    hi,hi

    nothing??

  • Bug in Java

    Hi Guys ,
    i found a bug in java when doing this calculation..
    double a = 1741;
           double b = 81.1;
           double c = 0;
           double temp = (a-b-c);
           System.out.println("temp = "+temp);  //1659.9
           double total = (double)temp/1000;   //BUG HERE
           System.out.println("Res = "+total);  //1.6599000000000002I wonder if u guys get the same value as mine using above calculation.
    if i change the double b = 81.2 i works fine..

    I have good news and bad news for you. To end on a high note we'll leave the good news for last.
    The bad news is that you are the 6,137,215th person to report this "bug" yet Sun will not be fixing it.
    The good news is that the bad news doesn't matter because... <drumroll please/>.....
    It is NOT a bug. The only bug here is your lack of understanding floating point arithmetic. I refer you to the following article http://docs.sun.com/source/806-3568/ncg_goldberg.html

  • FAQ: I found a bug. How do I write a useful bug report? Or send bug files to Adobe?

    If you think you've found a bug in Photoshop CS6, please post your findings here on the forums.
    Here is a list of the information we'll want for you to gather at a minimum:
    Clear and concise steps so that someone who isn't in front of your comptuer can reproduce the issue you are seeing
    Include information on the operating system/version you are running. (e.g. "Mac OS 10.7.3" or "Win XP Service Pack 3")
    Here are some more detailed instructions for writing a useful, complete bug report for us on the forums:
    Provide a descriptive title that includes your OS information:Example: "Photoshop crashes when I save a JPEG file using the File>Save For Web & Devices... command (Mac OS 10.7.3)"
    Provide concise, step-by-step details on how to reproduce the issue you are seeing.
    Example:
    Open an 8-bit, RGB image by selecting File>Open...
    Create a new layer by clicking the "Create New Layer" button on the bottom of the Layers panel
    Paint on the layer created in Step #2 using the default Brush tool
    Choose File>Save For Web & Devices...
    Make sure the optimized format is set to "JPEG" and set the Quality setting to "80"
    Click the Save button at the bottom of the Save For Web & Devices dialog, choose the desktop as the location for saving the file
    Provide a description of the "Result" you are observing:
    Example: "Result: Photoshop crashes"
    If there is an error dialog, please include the exact wording displayed in the dialog or provide a screen shot or video of the entire screen so we can see the dialog as well as the state of the application - i.e. what panels are shown, the state of the Layers panel, etc.
    If the error is a visual defect, either in the user interface or the image itself, provide a screen shot or video of the entire screen so we can see the dialog as well as the state of the application - i.e. what panels are shown, the state of the Layers panel, etc.
    Provide a description of the "Expected Result":
    Example: "Expected Result: Photoshop to save JPEG file to the desktop, no crash"
    In some cases this may be obvious (such as in the case of a crash) but in others, what you expect to happen may be different than what the application was designed to do. Please be as specific as possible.
    Provide the crash log by submitting all crash reports, including your email address, for every single crash your encounter:
    You may also include the contents of your crash log in your forum posts as well, but always submit them using the above instructions as well.
    Crash logs are located on Macintosh here: Users/<your user name>/Library/Logs/CrashReporter
    Provide your System Info from Photoshop: What's even more useful is if you can share your System Info from Photoshop as it contains all kinds of useful information (OS/version, graphics card, driver version, 3rd party plug-ins used, etc) that will help the team track down your issue.
    On occasion, the Photoshop engineers may request that you provide problematic files in order to reproduce and debug your issue.
    In these cases, please post the file somewhere using your own servers or one your favorite online document/distribution services and provide a URL/instructions to download the file:
    Dropbox
    Adobe SendNow
    YouSendIt
    If the file isn't something you can post publically, you can request that someone from the engineering team contact you to figure out a secure way to get the affected files.
    Thanks,
    The Photoshop Development Team

    First thing would be to realise the exact error. Second would be to check your logs to see what you have installed/upgraded which might be causing this error. Third, google your error and see if matches turn up. Fourth, search in Arch bugtracker to see if a match exist. Else file a report.

  • A possible *bug* in java jcombobox

    Hi all,
    I think i found a possible bug in java jcombobox .. i am sure some of you must have already experienced it..
    supposedly you put a jcombobox in a jpanel
    returned the panel from a method to a calling method..
    and that method adds it to another panel that it had created to a frame..
    and if this happens dynamicaly at runtime, as only after u click a button..
    meaning : without adding the combobox or the immediate parent panelto the contentpane .. directly..
    Then,
    your combox's keylistener may not catch events fired.
    .. this has happened to me many times.. and always i could only find a way out
    .. by adding the combobox to panel that is loaded during startup itself and is
    .. not returned through a method call.
    Your opinions please ?
    'Harish.

    All components in a UI are created at run-time.
    When you create your JFrame you call pack() to align and resize the UI. This validates all the components, and sets the default focus on what ever component should have the focus at start up.
    When you create components and add them as children of another component you have to validate the child and parent. This can be done by calling JComponent.validate()
    As for keylisteners not getting called, this might be fixed if you call grabFocus on the new combobox. I can't see a reason why any listener would stop working.
    For me to really understand what your talking about. I'd need to see source code reproducing this problem.

  • I found a bug in iOS 4.3.3 - Long voice memos

    Hello,
    i found a bug in iOS 4.3.3 for my iPhone 3GS
    Long voice memos can not be played
    In these cases, the iPhone saves the file not in the format M4A or can not open this file.
    This file is stored in the folder /var/mobile/Media/Recordings
    In This cases there can be find a file in the format MOV.
    During recording, the voice memo has the format MOV.
    When the voice memo stopped the file must be stored in the format M4A.
    For large files, there are currently problems.
    I use the program  iPhone Explorer and save the MOV-file on my computer.
    Now i can open it with QuickTime.
    Best regards from Germany!
    Ruediger

    Apple Feedback

  • I think I've found a bug... (CS 4 6.0.4, export to EPUB, w/ test case)

    Hi everyone,
    I think I've found a bug. I suppose I would like to see if others can reproduce it - I've managed to on 2 work machines, but the more the merrier. I suppose I'm also hoping that giving this bug more exposure will increase the likelihood of it getting resolved. I can dream
    The bug shows itself when exporting an InDesign document (or book) to "Digital Editions", or as an EPUB file. The InDesign source needs to have a Table of Contents, and this TOC has to be used by the EPUB to create TOC entries (see the "contents" tab of the export window). In certain cases, using the InDesign TOC causes the EPUB export to garble certain characters; unicode-specific characters, in my experience.
    Steps to reproduce:
    Create a new document, add a blank text frame and fill it with placeholder text. add a heading to this text frame, styled appropriately.
    Create a table of contents, using the heading style you defined and used previously.
    Add some unicode characters to the end of your text frame. I've been using "bêche-de-mer — a genus", which has 2 unicode characters. My tests have shown about 1715 characters in the text frame is enough to trigger this bug.
    Save the document and export to digital editions. under the "contents" tab, check the "include indesign TOC entries" option.
    Open the EPUB (or unzip it and view the xhtml content). I would expect to see "bêche-de-mer — a genus" at the end. However, I see something more like "b√™che-de-mer ‚Äî a genus" instead. I do see the correct output if I don't check the "include indesign TOC entries" option when exporting to EPUB.
    I've confirmed the fonts I've tried are unicode-compliant and have the relevant character codes. I'm running the latest update to InDesign CS4 (6.0.4) on OSX 10.4.11. This character encoding problem doesn't manifest itself in the PDF or IDML export, only the EPUB export. Choosing whether or not to include embedded fonts in the EPUB doesn't make a difference to the outcome. I have run this test on my machine and a workmates, which is OSX 10.5.[something]
    I'll attach a test document to see if others can reproduce this bug. I'd be interested to hear if others can, or cannot reproduce it. I have submitted a bug report at https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform, but that doesn't exactly imbue me with confidence that anything will get done in a hurry...
    This problem is pretty annoying; I can either have EPUB navigation, or uncorrupt text. My current (proposed) workaround is for the operator to create 2 EPUBs, one with a TOC and one without, and merge the two together... EPUB transplant if you will. A bit ugly....
    thanks for listening!

    Hiya Joe (and Archie)
    It is indeed an annoying bug - I spent a few days looking around it before posting (wow, it must be nearly a year ago now).
    Fortunately, it really is straightforward (if a bit of a hassle) to workaround:
    - make 2 EPUBs, identical except one will have a TOC generated (epub-a), the other will not (epub-b)
    - extract the TOC file from epub-a and insert it into epub-b
    remembering that EPUB is a zip package, this is very easy indeed. On OSX you have /usr/bin/zip and /usr/bin/unzip to assist with extraction / insertion in a script (bash, applescript, etc). I don't think Windows comes with command-line zip programs, so you'd need to hunt around a bit.
    Good luck. I don't know if this is resolved in the latest 6.0.5 patch - if you haven't updated to that, it might be worth a shot. And if you have and it's still a problem, please respond to this message just so there's a log stating as much.
    Steve

  • I've found two bugs in iOS 7. 1) declined calls does not appear as missed calls on the lock screen/notification centre. 2) when bluetooth is enabled from control center, it does not connect to an already paired bluetooth device

    I've found two bugs in iOS 7:
    1) declined calls does not appear as missed calls on the lock screen/notification centre - iOS 7.0.2.
    2) when bluetooth is enabled from control center, it does not connect to an already paired bluetooth device automatically - iOS 7.0.

    We are all users here, just like you, but you can tell Apple about it by using this link:
    Apple - iPhone - Feedback

  • Dear Apple, unfortunately, I think I have found a bug in ios 7. During an incoming call is no call rejection or selection of the ability to send a text message. I hope it is a bug and there is a solution. Thank you very much.

    Dear Apple, unfortunately, I think I have found a bug in ios 7. During an incoming call is no call rejection or selection of the ability to send a text message. I hope it is a bug and there is a solution. Thank you very much.

    Please report via Apple Feedback. These are user forums. You aren't speaking to Apple here.

  • I Have found a bug in iOS 7.1 on iPhone 4S ? What should i do ?(i'm french)

    I Have found a bug in iOS 7.1 on iPhone 4S, what shoud I Do ? (i'm french)

    Use the contact us link at the bottom of the page and tell Apple.

  • Already found a BuG in the PR1.2

    sins this morning the new PR1.2 is availeble.
    Not much changes.
    Already found a BuG
    The Calender Noticing (Bday warning) for missed calender warning
    When unloching the phone and accept the missed warning.
    You get on the screen with the (Bday) notification.
    After that you can't close the screen with the CLOSE button below right anymore.

    Also, the yahoo email client always connects to the internet after the phone is powered on.
    Model N8, Dark Gray

  • I found a bug in multitasking in ios 7, how can I submit this bug to apple to help engineers fix it

    I found a bug, how can I pass it on to apple engineers to help them fix it

    I recall hearing (in another post, maybe yesterday) of a multitasking bug that Apple engineers were asking a user to test...I'll see if I can find it.
    EDIT: Starting at the bottom on page 2 (how to test) and continuing with more details for testing on page 3 https://discussions.apple.com/message/23666433#23666433

  • I found a bug in the gamma (when watching some videos) Ipad 4 wifi+4 G

    I found a bug in the gamma  (Ipad wifi 4 Wifi+4G). It is the same bug as the ipad 2 at release.If you try to play any video (youtube, apple trailer, your own converted video) on the iPad 4, any black images will turn grayish. Ask fixing!!! Support pls help meee...
    P.S Sorry for my Eng (see nickname)

    This is an iPad user to user forum. Apple doesn'y read or respond.
    Send feedback to Apple.
    http://www.apple.com/feedback/ipad.html
     Cheers, Tom
    PS Your English is good!!!!!!!!!!!

  • Found a bug in the Convert widget how to report ?

    Hello, i found a bug in the default convert widget delivered by apple, how can i let them know if this bug ? (it's not crashing, it's a big calculation error)
    Thanks,

    Fill out and submit this form.
    (23177)

  • No possible entries found

    Hello,
    We have defined all the variables for the materials. However, when I attempt to use Material
          Matchcode object MAT1, I get the response "No possible entries found". Why?

    Hi Ganesh,
    Matchcode (id: B) is only related to materials wherein Bill of Material (STLNR - BOM# in table MAST) is associated to it.
    Now, this message - "No possible entries found" pops up -  if there are no BOM's associated with said material number.
    Hope this clarifies the issue.
    Thank you,
    S Datta

Maybe you are looking for

  • Delta Loads are not working: 0FI_GL_10 With enhancement : HR Data in source

    Hello Friends. Thanks for your answer on theory which I know, Please help me with this situation. I read all the sdn response to my message and have below for your suggestion QUES1: Why the 0RECORDMODE is not coming in Standard DSO and hence it is no

  • How do I save as PDF/A, PDF/A-1b in Acrobat XI Strandard?

    How do I save as PDF/A, PDF/A-1b compliant in Acrobat XI Strandard?  I want to archive some of my PDF files.  I want them to meet generally used archived standards.  My install of ACrobat Standard was a standard install.  Is this something I can only

  • How Bea Weblogic works

              Hi all           I have another question, that is how bea weblogic cluster works...           I have a linux box as a load balancer, running LVS on it.           I use Direct Routing mode load balancing. In my former experience, all the    

  • WEBUTIL demo on OC4J

    Has anyone had success running the WEBUTIL demo from the OTN site using OC4J and running Oracle Developer Suite 10g (10.1.2.0.2), this version has the WEBUTIL wrapped in it. I can see the runtime form but immediately get a trigger error, it has somet

  • ThInit: db_connect error

    Hi... unable to start the sap server.. disp+work.exe (dispacher) stopped.. trc file: "dev_w0", trc level: 1, release: "700" ACTIVE TRACE LEVEL           1 ACTIVE TRACE COMPONENTS      all, MJ B  B Thu Feb 23 14:35:53 2012 B  create_con (con_name=R/3)