use*_*490 0 javascript regex substring
我正在尝试使用正则表达式获取大括号内的子字符串。
假设我有以下字符串:
"This is a {nice} text to search for a {cool} substring".
Run Code Online (Sandbox Code Playgroud)
我希望能够搜索nice并cool
尝试如下:
var myString = "This is a {nice} text to search for a {cool} substring",
pattern = /[^{}]*(?=\})/g;
console.log(myString.match(pattern));Run Code Online (Sandbox Code Playgroud)