开发者

Optimizing Regular Expression

开发者 https://www.devze.com 2023-03-09 15:05 出处:网络
I have one regular expression which convert html to txt. But It is taking a lot of CPU usages . How开发者_高级运维 can I optimize it ?

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

精彩评论

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

关注公众号