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

108
Views
fetch src value from the string

correct regex to fetch src value from the string.

 var str = "<iframe width=\"1000\" height=\"460\" src=\"https://myvideo.dpdhl.com/video/CuEt8XJ8uVEU3MZrrjQp5z\" title=\"Test Video for New Component\"></iframe>";
    
 var re = /^src/g;
 var n = str.match(re);
 console.log(n);

//output &quot;https://myvideo.dpdhl.com/video/CuEt8XJ8uVEU3MZrrjQp5z&quot; title=&quot;Test Video for New Component&quot;></iframe>

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

0

We can try using match with the regex pattern \bsrc=\S+:

var str = "&lt;iframe width=\&quot;1000\&quot; height=\&quot;460\&quot; src=\&quot;https&#58;//myvideo.dpdhl.com/video/CuEt8XJ8uVEU3MZrrjQp5z\&quot; title=\&quot;Test Video for New Component\&quot;&gt;&lt;/iframe&gt;";
var src = str.match(/\bsrc=\S+/);
console.log(src);

about 4 years ago · Juan Pablo Isaza Report

0

If you know your input will always look like this or similar, you can also just use replace:

const str = "&lt;iframe width=\&quot;1000\&quot; height=\&quot;460\&quot; src=\&quot;https&#58;//myvideo.dpdhl.com/video/CuEt8XJ8uVEU3MZrrjQp5z\&quot; title=\&quot;Test Video for New Component\&quot;&gt;&lt;/iframe&gt;";

const src = str.replace(/^.*?src=\&quot;(.*?)\&quot;.*?$/, "$1");

console.log(src);

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!