public static int findNthUnescaped(char charToFind,int n,String s){
  char[] charArray=s.toCharArray();
  int count=0;
  for (int i=0; i < charArray.length; ++i) {
    if (i > 0 && charArray[i - 1] == '\\')     continue;
    if (charArray[i] == charToFind) {
      if (++count == n) {
        return i;
      }
    }
  }
  return -1;
}

public static int findNthUnescaped ( char charToFind , int n , String s ) { char [ ] charArray = s . toCharArray ( ) ; int count = 0 ; for ( int i = 0 ; i < charArray . length ; ++ i ) { if ( i > 0 && charArray [ i - 1 ] == '\\' ) continue ; if ( charArray [ i ] == charToFind ) { if ( ++ count == n ) { return i ; } } } return - 1 ; }
find the index of the first unescapped ( using backslash ) character
