admin管理员组文章数量:1278985
I'm trying to remove all from a string.
runReportReq.responseText.replace(/\<style>.*?\</style>/, '')
Can anyone show me where I'm going wrong?
I'm trying to remove all from a string.
runReportReq.responseText.replace(/\<style>.*?\</style>/, '')
Can anyone show me where I'm going wrong?
Share Improve this question asked Aug 16, 2012 at 13:42 Mark PriceMark Price 5901 gold badge8 silver badges19 bronze badges 3- 1 Notice where syntax highlighting breaks. – Oleg V. Volkov Commented Aug 16, 2012 at 13:52
- 1 Are you trying to remove the style tags along with the string inside? Or only the string inside the tags? You can do quick syntax checks as described in my answer below. – Kash Commented Aug 16, 2012 at 13:57
- It didn't matter to me if I removed the tags or not – Mark Price Commented Aug 16, 2012 at 14:28
4 Answers
Reset to default 8Try this:
runReportReq.responseText.replace(/<style>.*?<\/style>/g, '')
You can test the validity of the regex syntax here for JavaScript with sample code:
Regex Tester
You can test the regex itself with sample input here for JavaScript:
RegexPal
You've not escaped the right character, try with:
/<style>.*?<\/style>/
You need backreferences...
The regex:
(\<style\>).+(/\<style\>)
Would allow you to replace with backreferences by $1$2
So, <style>asdasd</style>
would result in <style></style>
replace returns the processed string, so you have to store the result anywhere
see http://www.w3schools./jsref/jsref_replace.asp
版权声明:本文标题:jquery - Regex to match everything between <style> and <style> Then Remove with Javascript - Stack O 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741233904a2362625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论