Bug 16434 - underscore not matched
underscore not matched
Status: CLOSED DUPLICATE of bug 14954
Product: Regexp
Classification: Unclassified
Component: Other
unspecified
Other other
: P3 major (vote)
: ---
Assigned To: Jakarta Notifications Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2003-01-26 19:43 UTC by Leo Mekenkamp
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Mekenkamp 2003-01-26 19:43:47 UTC
/* Example code is always best for reporting bugs. I could have made it a bit
 * more easy, but I'm tired (sorry). The Sun 1.4.0_01-b03 SDK I have run this
 * on seems to disagree with jakarta's regexp; I am inclined to believe Sun is
 * right...
 */

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.regexp.RE;

public class X {

    public final static String METHOD = "^[ \\t]*public[
\\t]+[_a-zA-Z][_a-zA-Z0-9\\.\\[\\]]*[ \\t]+([_a-zA-Z][\\w]*)[ \\t]*\\(";

    public final static String ok = "public void foo(";
    public final static String error = "public void _foo(";
    
    public static void main(String[] args) throws Exception {
        
        RE re = new RE(METHOD);

        System.out.println("sun: " + Pattern.matches(METHOD, ok) + ", apache: "
+ re.match(ok));
        System.out.println("sun: " + Pattern.matches(METHOD, error) + ", apache:
" + re.match(error));

    }
 
}
Comment 1 Vadim Gritsenko 2003-04-25 12:36:31 UTC

*** This bug has been marked as a duplicate of 14954 ***
Comment 2 Vadim Gritsenko 2003-05-02 01:14:16 UTC
Fixed by Bug #19329