Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda