function magicMatch(text) {
var matches = text.match(/^[^\,]+\,.+\((.+)\)$/);
if (matches && matches[1]) {
return matches[1];
}
return text;
}
console.log( magicMatch('Saglek, CA (YSV)') ); // YSV
console.log( magicMatch('Saglek Xxx city, CA (YSV)') ); // YSV
console.log( magicMatch('Saglek') ); // Saglek
console.log( magicMatch('Saglek ` Great City (town-city)') ); // Saglek ` Great City (town-city)
var startTime = 45;
var audio = document.createElement('audio');
audio.preload = 'auto';
audio.autoplay = false;
audio.src = '/path/to/song.mp3'
document.body.appendChild(audio);
audio.addEventListener('canplaythrough', function() {
this.currentTime = startTime;
this.play();
}, false);