Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a string that looks like this:(我有一个看起来像这样的字符串:)

0000000020C90037:TEMP:data(0000000020C90037:TEMP:数据) And I need to grab everything after the first colon, so that I have TEMP:data.(我需要在第一次冒号之后抓住所有内容,以便我有TEMP:数据。) I don't often work in Javascript, if it were PHP I would do this:(我不经常使用Javascript,如果它是PHP我会这样做:) $str = '0000000020C90037:TEMP:data'; $arr = explode(":", $str); $var = $arr[1].":".$arr[2];   ask by Doug Molineux translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
294 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is a direct conversion from your PHP code:(这是从PHP代码直接转换:)

//Loading the variable var mystr = '0000000020C90037:TEMP:data'; //Splitting it with : as the separator var myarr = mystr.split(":"); //Then read the values from the array where 0 is the first //Since we skipped the first element in the array, we start at 1 var myvar = myarr[1] + ":" + myarr[2]; // Show the resulting value console.log(myvar); // 'TEMP:data'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...