private static CharSequence stripAndFlatten(String text) {
    Matcher m = pattern.matcher(text);
    StringBuffer sb = new StringBuffer();
    while (m.find()) {
      String replacement;
      String backslashesToEscape = m.group("backslashesToEscape");
      if (backslashesToEscape != null) {
        replacement = backslashesToEscape + backslashesToEscape;
      } else if (m.group("whitespacesToCollapse") != null){
        replacement = " ";
      } else {
        replacement = "";
      }
      m.appendReplacement(sb, replacement);
    }
    m.appendTail(sb);
    return sb;
  }
Runtime representation of an evaluated condition.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/runtime/Condition.java