code: public static int findNumberOfSpacesInWord(String word) {
          int count = 0;
          for (int i = 0; i < word.length(); i++)
              if (word.charAt(i) == SPACE_CHAR && (i == 0 || word.charAt(i - 1) != BACK_SLASH))
                  count++;
  
          return count;
      }
docs: find number of spaces in the given word. escaped spaces are not counted
  
  @param word to check
  @return number of spaces