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

270
Views
How to use regex to match an IPFS URL?

I have the following IPFS URL.

https://example.com:2053/ipfs/QmPQeMz2vzeLin5HcNYinVoSggPsaXh5QiKDBFtxMREgLf/images/0000000000000000000000000000000000000000000000000000000000000001.png

I want to use regex to match this file, but instead of writing the full URL, I want to just match something like https*00000001.png.

The problem is that when I use

  paddedHex = '00000001';
      let tmpSearchQuery = `https*${paddedHex}.png`;

It doesn't really match anything. Why?

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

0

You are repeating an s char zero or more times using s* and to create a dynamic regex you have to use the RegExp constructor.

You can repeat optional non whitespace chars instead using \S* and if you want to match http and https make the s optional using s?

const s = `https://ipfs.moralis.io:2053/ipfs/QmPQeMz2vzeLin5HcNYinVoSggPsaXh5QiKDBFtxMREgLf/images/0000000000000000000000000000000000000000000000000000000000000001.png`;
const paddedHex = '00000001';
const tmpSearchQuery = new RegExp(`https?\\S*${paddedHex}\\.png`);
const m = s.match(tmpSearchQuery);

if (m) {
  console.log(m[0]);
}

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!