Regex help -- cleaning up whitespace -- Java
Posted
by FarmBoy
on Stack Overflow
See other posts from Stack Overflow
or by FarmBoy
Published on 2010-05-28T14:43:46Z
Indexed on
2010/05/28
14:51 UTC
Read the original article
Hit count: 274
I'm trying to view the text of HTML files in a reasonable way. After I remove all of the markup and retain only the visible text, I obtain a String that looks something like this:
\n\n\n\n \n\n\n \n\n \n Title here \n\n\n \n\n \n\n Menu Item 1 \n\n \n\n Menu Item 2 \n\n\n \n\n you get the point.
I would like to use String.replaceAll(String regex, String regex)
to replace any whitespace substring that contains more than two occurances of \n
with "\n\n"
.
Any ideas?
© Stack Overflow or respective owner