private static String wikiToPlainText(String content){
  content=content.replaceAll("\\[\\[[iI]mage:[^\\]]*\\]\\]","");
  content=content.replaceAll("(?s)<!--.*?-->","");
  content=content.replaceAll("(?s)<ref>.*?</ref>","");
  content=content.replaceAll("(?s)\\{\\{([^{}]*?\\{\\{[^{}]*?\\}\\})+[^{}].*?\\}\\}","");
  content=content.replaceAll("(?s)\\{\\{.*?\\}\\}","");
  content=content.replaceAll("(?s)\\{\\|.*?\\|\\}","");
  content=content.replaceAll("\\[\\[[^\\]]*\\|","");
  content=content.replaceAll("\\[\\[","");
  content=content.replaceAll("\\]\\]","");
  content=content.replaceAll("(?s)<.*?>","");
  content=content.trim();
  final int size=content.length();
  int endOfFirstParagraph=content.indexOf("\n",50);
  if (endOfFirstParagraph < 0) {
    endOfFirstParagraph=size;
  }
  content=content.substring(0,Math.min(endOfFirstParagraph,1024));
  return content;
}

private static String wikiToPlainText ( String content ) { content = content . replaceAll ( "\\[\\[[iI]mage:[^\\]]*\\]\\]" , "" ) ; content = content . replaceAll ( "(?s)<!--.*?-->" , "" ) ; content = content . replaceAll ( "(?s)<ref>.*?</ref>" , "" ) ; content = content . replaceAll ( "(?s)\\{\\{([^{}]*?\\{\\{[^{}]*?\\}\\})+[^{}].*?\\}\\}" , "" ) ; content = content . replaceAll ( "(?s)\\{\\{.*?\\}\\}" , "" ) ; content = content . replaceAll ( "(?s)\\{\\|.*?\\|\\}" , "" ) ; content = content . replaceAll ( "\\[\\[[^\\]]*\\|" , "" ) ; content = content . replaceAll ( "\\[\\[" , "" ) ; content = content . replaceAll ( "\\]\\]" , "" ) ; content = content . replaceAll ( "(?s)<.*?>" , "" ) ; content = content . trim ( ) ; final int size = content . length ( ) ; int endOfFirstParagraph = content . indexOf ( "\n" , 50 ) ; if ( endOfFirstParagraph < 0 ) { endOfFirstParagraph = size ; } content = content . substring ( 0 , Math . min ( endOfFirstParagraph , 1024 ) ) ; return content ; }
extract plain text from wikipedia article content .
