简体   繁体   English

javascript match() 不带斜线

[英]javascript match() without slash

I found this code:我找到了这段代码:

var k= 'test';

var m = document.cookie.match(k+'=([^;]*)'); 

and I'm trying to get which cookies will be read.我正在尝试获取将读取哪个 cookies 。 Normally there is a leading slash in the regex like: x.match (/\d+/g);通常,正则表达式中有一个前导斜杠,例如: x.match (/\d+/g); but not here, so my question is how has the cookie to look like?但不是在这里,所以我的问题是 cookie 的外观如何?

See the documentation on MDN :请参阅MDN 上的文档

If regexp is a non-RegExp object, it is implicitly converted to a RegExp by using new RegExp(regexp).如果 regexp 是非 RegExp object,则使用 new RegExp(regexp) 将其隐式转换为 RegExp。

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

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