开发者

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]*;


Use an HTML parser if you can. Regex is bad for HTML for various reasons, and performance will inevitably suffer as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜