Intercept js strings and ask for advice

* * var str = "1048964" 1048965 "1048966" 1048967 "1048968"; beg on your knees!
how does jquery get the second and third value;
the expected result after intercepting the string is: 1048965 / 1048966 *

Mar.23,2021

var arr = str.split('_'),  //arr=[1048964,1048965,1048966,...]
arr
var newarr = arr.slice(1,2) //newarr

str.split ('_') [1] +'_'+ str.split ('_') [2]


length is fixed, direct calculation of position
length is not certain. Write regular expression


can first be divided into arrays with split, and then take the corresponding items for splicing.


str.match (/ ^ dongs _ (dcards /) /) [1]

clipboard.png

Menu