Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Javascript cookie.match

I have a cookie that I am trying to match it works fine on the online tool but not in the Chrome console using the [\w+]. Any help would be great.

cookie Name customerid value =2488475 

In Chrome console, I am trying document.cookie.match('customerid=document.cookie.match('customerid=([\w+])*'); but it is returning null

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As Barmar said when using Regular expressions match method take //, not ''.

follow pattern string.match(regexp), So change single quotes with slash

document.cookie.match('customerid=[\w+]');
//                    ^                ^

Note: The match() method returns the matches in an array and null if no match is found.

To get a value from cookie with regex Ref:

window.getCookie = function(name) {
  var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
  if (match) return match[2];
}

In your case call the function getCookie('customerid')

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!