Postman(Pre-requestScript)之截取字符串⼀、slice截取字符串
截取倒数第⼏位的字符串时,可以⽤slice⽅便获取
var test_string = "abc123456"
//截取倒数六位字符串
var new_string = test_string.slice(-6);
//截取第⼀位到第三位字符
var new_string1 = test_string.slice(0,3);
console.log('=====new_string:' + new_string);
console.log('=====new_string1:' + new_string1);
⼆、substring截取字符串
substring⽆法倒数截取字符串
var test_string = "abc123456"
//截取第⼆位到第五字符串
var new_string = test_string.substring(1,6);
//截取第⼀位到第三字符串
substring和slicevar new_string1 = test_string.substring(0,3);
console.log('=====new_string:' + new_string);
console.log('=====new_string1:' + new_string1);