Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
除去Javascript/JQuery中第一组引号之外的任何内容_Javascript_Jquery_Regex - Fatal编程技术网

除去Javascript/JQuery中第一组引号之外的任何内容

除去Javascript/JQuery中第一组引号之外的任何内容,javascript,jquery,regex,Javascript,Jquery,Regex,我不想删除此字符串中第一组引号之外的任何字符: toastr.warning("Cynthia Open Chat and respond to request","",{"timeOut":5000,"progressBar":true,}) 结果是辛西娅G.打开聊天室并响应请求 我本来打算这样做的,/\w.*(=“\w){1}/,但这似乎不起作用。更容易使用匹配: var str = 'toastr.warning("Cynthia Open Chat and respond to req

我不想删除此字符串中第一组引号之外的任何字符:

toastr.warning("Cynthia Open Chat and respond to request","",{"timeOut":5000,"progressBar":true,})
结果是辛西娅G.打开聊天室并响应请求


我本来打算这样做的,
/\w.*(=“\w){1}/
,但这似乎不起作用。

更容易使用
匹配

var str = 'toastr.warning("Cynthia Open Chat and respond to request","",{"timeOut":5000,"progressBar":true,})';

var repl = str.match(/"[^"]*/)[0].substring(1);
//=> Cynthia Open Chat and respond to request

易于使用的
匹配

var str = 'toastr.warning("Cynthia Open Chat and respond to request","",{"timeOut":5000,"progressBar":true,})';

var repl = str.match(/"[^"]*/)[0].substring(1);
//=> Cynthia Open Chat and respond to request

尝试使用此
RegExp

var str = 'toastr.warning("Cynthia Open Chat and respond to request","",{"timeOut":5000,"progressBar":true,})';

var text = str.replace(/^[^"]*?"([^"]+)".*$/, "$1");
// Cynthia Open Chat and respond to request

尝试使用此
RegExp

var str = 'toastr.warning("Cynthia Open Chat and respond to request","",{"timeOut":5000,"progressBar":true,})';

var text = str.replace(/^[^"]*?"([^"]+)".*$/, "$1");
// Cynthia Open Chat and respond to request

为什么不在名为
toastr
的对象中创建一个名为
warning
的函数,并通过
eval
调用它来获取第一个参数?或者源不可信?为什么不在名为
toastr
的对象中创建一个名为
warning
的函数,并通过
eval
调用它来获取第一个参数?或者来源不可信?