繁体   English   中英

获取与JQuery / Javascript或正则表达式中的模式匹配的所有字符串

[英]Get all strings that match a pattern in JQuery/Javascript or regular expression

我在正则表达式方面很糟糕,需要帮助来获取所有以[开头和以]结尾的字符串。

Example: "This is the match [*more*] or [*less*]" 

And I want to get [*more*], [*less*] into an array

我已经尝试过类似的操作,但是它是不正确的: /\\[\\*([^}]+)\\*\\]/g

尝试这个:

var str = "This is the match [more] or [less]";
var you_arr = str.match(/(\[.*?\])/g);

结果your_arr :( ("[more]","[less]")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM