Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Octal constant confusion in regexps

tlhackque
2012-10-22
2013-05-28
  • tlhackque
    tlhackque
    2012-10-22

    I think I have a case of JSLint being confused, though I'm not a javascript language lawyer.

    In a regexp, I have octal constants, but get what I believe is an incorrect warning.  If I switch to the equivalent hex constants (\x02 etc), JSLint is happy.  Here is the code in question.

        O:\scripts.js(890): warning: non-octal digit in an escape sequence that doesn't match a back-reference
                        var kpair = items[i].split( /(\002|\003)/ );
        ............................................^
        O:\scripts.js(890): warning: non-octal digit in an escape sequence that doesn't match a back-reference
                        var kpair = items[i].split( /(\002|\003)/ );
        ............................................^
        O:\scripts.js(900): warning: non-octal digit in an escape sequence that doesn't match a back-reference
                            var newval = kpair[2].split( /\004/ );
        .................................................^
    

    I'd rather not change the constants as they are octal in the corresponding server-side code.

    If I'm confused, how should I be specifying these octal constants?  If it's JSLint, does this suffice as a bug report?

    Thanks!