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

114
Views
How to capture all 13 digits after that regex non-capture group

I'm trying to capture a SKU of a product from localstorage in javascript

the item is a html string and i'm trying to figure out a regex that capture that SKU id

the localstorage return looks like this:

<li class="cart__item">SKU: MLB2046549757 | NAME: Notebook Multilaser Legacy Book Pc310 Preta 14.1 , Intel Celeron N3000 4gb De Ram 64gb Ssd, Intel Hd Graphics 1366x768px Windows 10 Home | PRICE: $1415</li><li class="cart__item">SKU: MLB2046549757 | NAME: Notebook Multilaser Legacy Book Pc310 Preta 14.1 , Intel Celeron N3000 4gb De Ram 64gb Ssd, Intel Hd Graphics 1366x768px Windows 10 Home | PRICE: $1415</li>

i tried (?:SKU\: ){13} regex to get e.g. MLB2046549757 SKU id but it didn't worked.

I need to capture all 13 digits after SKU: and save it in an array.

Anyone have an idea how could i do that?

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

0

Try this:

(SKU:\s)(.{13})

(?<=SKU:\s)(.{13})

2nd regex will result only the 13 positions after SKU: See demo

-Cheers!

about 4 years ago · Juan Pablo Isaza Report

0

If you're confident that you have consistent content try: /(?<=SKU:\s)[\dA-Z]{13}/g

const items = document.querySelectorAll('li');

let SKU = [...items].flatMap(li => li.textContent.match(/(?<=SKU:\s)[\dA-Z]{13}/g));

console.log(SKU)
<li class="cart__item">SKU: MLB2046549757 | NAME: Notebook Multilaser Legacy Book Pc310 Preta 14.1 , Intel Celeron N3000 4gb De Ram 64gb Ssd, Intel Hd Graphics 1366x768px Windows 10 Home | PRICE: $1415</li>
<li class="cart__item">SKU: MLB2046585666 | NAME: Notebook Multilaser Legacy Book Pc310 Preta 14.1 , Intel Celeron N3000 4gb De Ram 64gb Ssd, Intel Hd Graphics 1366x768px Windows 10 Home | PRICE: $1415</li>

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!