Regular Expressions 101

Community Patterns

Cookie Value Finder By name

1

Regular Expression
PCRE (PHP <7.3)

/
gsScrollPos=(.*?);|gsScrollPos=(.*)
/
g

Description

When using javascript to get a cookie value by its name,

  1. Get the cookie string by document.cookie
  2. Use this pattern to get the proper value. Just replace the cookie name in my pattern.
  3. Use 1st or 2nd group(this is only used when your cookie name is last in the string)
Submitted by khpatel4991 - 9 years ago