Hi Everyone.
I have been working on some code that strips the HTML code out of an HTML
page leaving just the text on the page. At the moment this is what I have:
// Strip all tags
replacePattern = "<(.|\n)+?> ";
pageHTML = pageHTML.replac eAll(replacePat tern,"");
//Remove any HTML specific characters (e.g. " or &)
replacePattern = "&(.|\n)+?; ";
pageHTML = pageHTML.replac eAll(replacePat tern,"");
// Remove whitespace
replacePattern = "\\s{2,}";
pageHTML = pageHTML.replac eAll(replacePat tern," ");
Is there a way I can combine all four patterns into one expression so I can
make the code more efficient? I've not really worked with RegEx so any
advice would be most welcome. Can I do something like:
replacePattern = "[<(.|\n)+?>][&(.|\n)+?;][\\s{2,}]";
pageHTML = pageHTML.replac eAll(replacePat tern,"");
Thanks.
--
Best Regards
[color=blue][color=green][color=darkred]
>>> Andrew Dixon[/color][/color][/color]
I have been working on some code that strips the HTML code out of an HTML
page leaving just the text on the page. At the moment this is what I have:
// Strip all tags
replacePattern = "<(.|\n)+?> ";
pageHTML = pageHTML.replac eAll(replacePat tern,"");
//Remove any HTML specific characters (e.g. " or &)
replacePattern = "&(.|\n)+?; ";
pageHTML = pageHTML.replac eAll(replacePat tern,"");
// Remove whitespace
replacePattern = "\\s{2,}";
pageHTML = pageHTML.replac eAll(replacePat tern," ");
Is there a way I can combine all four patterns into one expression so I can
make the code more efficient? I've not really worked with RegEx so any
advice would be most welcome. Can I do something like:
replacePattern = "[<(.|\n)+?>][&(.|\n)+?;][\\s{2,}]";
pageHTML = pageHTML.replac eAll(replacePat tern,"");
Thanks.
--
Best Regards
[color=blue][color=green][color=darkred]
>>> Andrew Dixon[/color][/color][/color]
Comment