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

155
Views
Check for pattern match with UUIDv4 in JavaScript

I am looking for a pattern match with certain string before and after the uuid.

e.g.user/a24a6ea4-ce75-4665-a070-57453082c256/photo/a24a6ea4-ce75-4665-a070-57453082c256

const regexExp = new RegExp(/^user\/[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i);

console.log(regexExp.test("user/a24a6ea4-ce75-4665-a070-57453082c256")); // true

console.log(regexExp.test("user/a24a6ea4-ce75-4665-a070-57453082c256/photo")); // false

What I am expecting is to match user/{uuid}/* How to use a wildcard after the uuid?

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

0

If you want to match both, you can omit using the RegExp constructor as you are already using a literal and optionally match / followed by the rest of the string.

The [4] can be just 4

const regexExp = /^user\/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}(?:\/.*)?$/i;

See the regex101 demo.

const regexExp = /^user\/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}(?:\/.*)?$/i;

[
  "user/a24a6ea4-ce75-4665-a070-57453082c256",
  "user/a24a6ea4-ce75-4665-a070-57453082c256/photo",
  "user/a24a6ea4-ce75-4665-a070-57453082c256asdasd"
].forEach(s =>
  console.log(`${s} --> ${regexExp.test(s)}`)
);

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!