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

195
Views
how to remove part of a link?

I have this link: "sound:https://cdn.jsdelivr.net/gh/ArSrNa/CDN/audio/%E6%B5%85%E5%A0%B4%E4%BD%B3%E8%8B%97%20-%20love%20the%20way.mp3?"

I would like to remove this from the beginning of the link: "sound:", and this from the end "?" so that I can play the audio on the link.

this is what i have so far. Every help is welcome.

<audio id="myAudio">
<source src="sound:https://cdn.jsdelivr.net/gh/ArSrNa/CDN/audio/%E6%B5%85%E5%A0%B4%E4%BD%B3%E8%8B%97%20-%20love%20the%20way.mp3?" type="audio/mpeg">
</audio>



<button onclick="playAudio()" type="button">Play Audio</button>
<button onclick="pauseAudio()" type="button">Pause Audio</button> 

<script>
var x = document.getElementById("myAudio"); 

s = x.replace('[sound:','').replace(']','');


function playAudio() { 
  s.play(); 
} 

function pauseAudio() { 
  s.pause(); 
} 
</script>

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

0

<source src="https://cdn.jsdelivr.net/gh/ArSrNa/CDN/audio/%E6%B5%85%E5%A0%B4%E4%BD%B3%E8%8B%97%20-%20love%20the%20way.mp3" type="audio/mpeg">

This would achieve exactly what you wanted. Why need a script?

about 4 years ago · Juan Pablo Isaza Report

0

There will almost certainly be a more robust regex based answer to this but the simplest way in my eyes, if you can rely on the end of the string always ending in .mp3 is to do string replacement. So it seems you pretty much have it with a couple of minor mistakes.

This s = x.replace('[sound:','').replace(']',''); should be s = x.replace('sound:','').replace('.mp3?','.mp3');

Adding .mp3 to the replacement will ensure no other question marks are removed out of context

about 4 years ago · Juan Pablo Isaza Report

0

I'm guessing this is what you are trying to do:

myURLstring.split(/sound\:|\?|\]/)[1]

var string1 = 'sound:https://cdn.jsdelivr.net/gh/ArSrNa/CDN/audio/%E6%B5%85%E5%A0%B4%E4%BD%B3%E8%8B%97%20-%20love%20the%20way.mp3?'
var string2 = '[sound:https://cdn.jsdelivr.net/gh/ArSrNa/CDN/audio/%E6%B5%85%E5%A0%B4%E4%BD%B3%E8%8B%97%20-%20love%20the%20way.mp3]'
console.log(string1.split(/sound\:|\?|\]/)[1]);
console.log(string2.split(/sound\:|\?|\]/)[1]);

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!