javascript - What is the best way to extract the numbers out of this text -


  P1W2DT6H21M32S  

is the best way to get numbers out of here .

  w = weekd = day h = hourm = min s = sec  

something like this works for M and S, and so on Looks like I'm not doing it right.

  var time = "PT44M7S"; Var minute = time. Substring (2, time.indexOf ("M")); Var seconds = time.split ("M") [1]. Asbestring (0, time.spitit ("M") [1] .indexOf ("S"));  

You can split on letters, although you get leading and trailing spaces in Array will:

'P1W2DT6H21M32S'.split (/ [AZ] /)


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -