[英]How to get attribute inside square brackets with JavaScript
I want to get the value of the background attribute (background.jpg) inside square bracket like BBCode editor's and I tried this regexp 我想要像BBCode编辑器一样在方括号内获取background属性(background.jpg)的值,我尝试了此正则表达式
\[(\w+)[^\]]*](.*?)\[\/\1]/g
but it didn't work. 但这没用。
[code background="background.jpg"] Here some text [/code]
\[(\w+)[^\]]*?background="([^"]+)"[^\]]*\](.*?)\[\/\1]
Try this.See demo. 试试看。看演示。
http://regex101.com/r/lZ5mN8/8 http://regex101.com/r/lZ5mN8/8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.