static boolean containsUnicodeEscape ( String s ) { String esc = REGEXP_ESCAPER . regexpEscape ( s ) ; for ( int i = - 1 ; ( i = esc . indexOf ( "\\u" , i + 1 ) ) >= 0 ; ) { int nSlashes = 0 ; while ( i - nSlashes > 0 && ' ' == esc . charAt ( i - nSlashes - 1 ) ) { ++ nSlashes ; } // if there are an even number of slashes before the \ u then it is a // Unicode literal. if ( 0 == ( nSlashes & 1 ) ) { return true ; } } return false ; }
true if the JavaScript string would contain a Unicode escape when written out as the body of a regular expression literal .