Menu

#1262 RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION for regexes using capture groups.

2.0.3
closed-rejected
None
4
2014-08-15
2014-04-01
No

RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION is produced for Java 7 regexes using capture groups even though they are valid Java7 Regex Syntax. I am using the IntelliJ FindBugs plugin with a Java 7 project.

For example:

 Pattern somePattern = Pattern.compile("(?<someGroup>\\w*)");

produces the error:

Called method java.util.regex.Pattern.compile(String)
Error message: Look-behind group does not have an obvious maximum length near index 15
Regular expression "(? \w*)"
BadSyntaxForRegularExpression (RE)

Discussion

  • William Pugh

    William Pugh - 2014-04-04

    OK, I'm pretty sure that you are running FindBugs using Java 6. I tried the example you provided, and it produced a warning if I ran FindBugs using Java 6, but not if I ran FindBugs using Java 7.

    I'm not sure if we should be trying to handle this case (analyzing Java 7 code while running FindBugs with Java 6). FindBugs 3.0 requires Java 7, so this isn't an issue. Might be something to try to fix for FindBugs 2.0.4.

    Could you verify what version of Java you are using to run findbugs? If you can export the xml file from the analysis, you can look at the vm_version in the FindBugsSummary to verify.

     
  • William Pugh

    William Pugh - 2014-04-04
    • status: open --> pending-rejected
    • assigned_to: William Pugh
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-19
    • status: pending-rejected --> closed-rejected
    • Group: 3.0.0 --> 2.0.3
     

Log in to post a comment.