Vivek Goel
Vivek Goel

Reputation: 24150

Optimizing Regular Expression

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

Answers (1)

Francis Gilbert
Francis Gilbert

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

Related Questions