Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2018-10-18 05:30
Flavor·JavaScript

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

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