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

170
Views
How to extract key-value data from a string containing multiple cookies?

Does anyone have an idea for a regex that can match multiple cookies (name, value pairs, combined by '=' and separated by '; ') in a string. With my design I can only match one cookie so far.

^(?<cookie>(?<name>.+[^;])=(?<value>.*[^;])(;\s*)?)+$

I would like to respect all special characters that cookies can contain. I'd like to use a regex and not rely on split and other functions provided by js.

Thank you very much,

Cheers!

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

0

I slightly tweaked you regex to this: /(?<cookie>(?<name>[^=]+)=(?<value>[^;]+);\s*)/gm

For a test string: "name1=value1;name2=value2;"
This produces the matches:

match1: name1=value1;
cookie: name1=value1;
name: name1
value: value1

match2: name2=value2;
cookie: name2=value2;
name: name2
value: value2

Test here: https://regex101.com/r/CNZqnj/2

EDIT:
Made changes according to user 'The Fourth Bird's suggestions in the comment.

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!