var REGEX = new RegExp("(?=[hms])g")
var TIME = _GET('t', '0').split(REGEX)
var hours = TIME[TIME.indexOf('h')-1]
var minutes = TIME[TIME.indexOf('m')-1]
var seconds = TIME[TIME.indexOf('s')-1]
var HOURS = hours?('hours: '+hours):''
var MINUTES = minutes?('minutes: '+minutes):''
var SECONDS = seconds?('seconds: '+seconds):''
document.write('TIME RECIEVED:<br><br>'+HOURS+'<br>'+MINUTES+'<br>'+SECONDS)
this is the entire code. I basically wanted to see if I could mimick youtube’s video trick (put &t=XhYmZs to go to that time in a video)
The only missing thing is that I don’t know regular expressions >_<
What I need is to split the string "5h55m55s" into ['5','h','55','m','55','s'] instead of ['5', 'h55', 'm55', 's'], which is breaks my code. Oh yeah, and the _GET function is unimportant, it just obtains a string from the url, like php’s $_GET variable
So Obviously, the regex /(?=[hms])/ doesn’t work completely and I need to know how to get it to split both on the “left” and “right” of h, m, and s
Basically, the answer to this question is a regexp that splits, for example, "55m55s" into the array ['55','m','55','s']
You could something like…
jsFiddle.
This will drop times of
0. If that is possible, change thefilter()body toreturn a.length.