Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda