×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Gerrit Viljoen
Added: Apr 30, 2014 10:37 AM
Views: 1812
  1.     public static boolean isEscaped(CharSequence input, int pos, char escape) {
  2.         if (input == null) {
  3.             throw new NullPointerException("Missing [input] argument");
  4.         }
  5.  
  6.         int count = 0;
  7.         for (int a = pos - 1; a >= 0; a--) {
  8.             final char c = input.charAt(a);
  9.             if (c == escape) {
  10.                 count++;
  11.             } else {
  12.                 break;
  13.             }
  14.         }
  15.         return count % 2 != 0;
  16.     }