code: public static boolean matchesWholeInput(RegExpTree t, String flags) {
      if (flags.indexOf('m') >= 0) { return false; }
  
      if (!(t instanceof Concatenation)) {
        return false;
      }
  
      Concatenation c = (Concatenation) t;
      if (c.elements.isEmpty()) { return false; }
      RegExpTree first = c.elements.get(0), last = Iterables.getLast(c.elements);
      if (!(first instanceof Anchor && last instanceof Anchor)) { return false; }
      return ((Anchor) first).type == '^' && ((Anchor) last).type == '$';
    }
docs: True if, but not necessarily always when the, given regular expression
  must match the whole input or none of it.