0

I found this code:

var k= 'test';

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

and I'm trying to get which cookies will be read. Normally there is a leading slash in the regex like: x.match (/\d+/g); but not here, so my question is how has the cookie to look like?

0

1 Answer 1

5

See the documentation on MDN:

If regexp is a non-RegExp object, it is implicitly converted to a RegExp by using new RegExp(regexp).

Sign up to request clarification or add additional context in comments.

6 Comments

do you have any example how the cookie look like?
@hamburger it would match that regex. So test= followed by any amount of non-; characters.
thats means the regex ist between the brackest [^;]* and the cookiename must contain an equal signe?
@hamburger — No. The whole string will be converted to a regular expression.
so the cookiename has to look like this: test=(hello)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.