static String applyTextElementSpacePolicy(String in){
  String out=in.replaceAll("\r\n","\n");
  out=out.replaceAll(" *\n *","\n");
  out=out.replaceAll("\n"," ");
  out=out.replaceAll("[ \t\\x0B\f\r]+"," ");
  return out;
}

static String applyTextElementSpacePolicy ( String in ) { String out = in . replaceAll ( "\r\n" , "\n" ) ; out = out . replaceAll ( " *\n *" , "\n" ) ; out = out . replaceAll ( "\n" , " " ) ; out = out . replaceAll ( "[ \t\\x0B\f\r]+" , " " ) ; return out ; }
applies the appropriate space policy to the given text element .
