Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
(?:(?:^|.*;\s*)test2\s*\=\s*([^;]*).*$)|^.*$
/

Description

Finds the value of a specific cookie. Use it in in this format:

alert(document.cookie.replace((?:(?:^|.*;\s*)test2\s*\=\s*([^;]*).*$)|^.*$))

The above code will find the value of the cookie called test2 and display it in a alert dialog.

Submitted by anonymous - 6 years ago