static String convertFromHtml ( final String textToConvert ) { //LinkedHashmap since the order matters final Map < String , String > regexps = new LinkedHashMap <> ( ) ; regexps . put ( "< *a *href=[\'\"](.*?)[\'\"] *>(.*?)</ *a *>" , "$2 ($1)" ) ; regexps . put ( "< *a *href=[\'\"](.*?)[\'\"] *>(.*?)< *a */>" , "$2 ($1)" ) ; regexps . put ( "</ *(br|p|table|h[1-4]|pre|hr|li|ul) *>" , "\n" ) ; regexps . put ( "< *(br|p|table|h[1-4]|pre|hr|li|ul) */>" , "\n" ) ; regexps . put ( "< *(p|table|h[1-4]|ul|pre) *>" , "\n" ) ; regexps . put ( "<li>" , " - " ) ; regexps . put ( "</th>" , "\t" ) ; regexps . put ( "<\\w*?>" , "" ) ; return regexps . entrySet ( ) . stream ( ) . sequential ( ) . reduce ( textToConvert , ( string , entrySet ) -> string . replaceAll ( entrySet . getKey ( ) , entrySet . getValue ( ) ) , ( a , b ) -> b ) ; }
package local for testing