Reputation: 24150
I have one regular expression which convert html to txt. But It is taking a lot of CPU usages . How can I optimize it ?
((\n|\r){2,}) | (\r|\n)|<head.*?</head>|<script.*?</script> |<meta[^>]+>|<style.*?</style> | <[^>]*> |&[^\s]*;
Upvotes: 1
Views: 172
Reputation: 3442
Use an HTML parser if you can. Regex is bad for HTML for various reasons, and performance will inevitably suffer as well.
Upvotes: 1