js中:
//1. 使用正则表达式判断是否已 ^^ 开始 //2. 调用字符串的 replace(reg, str) 方法除去指定的字符串. var str = "^^abc"; var reg = /^^{2}/g; alert(reg.test(str)); //true str = str.replace(reg, ""); alert(str); var str2 = "abc"; alert(reg.test(str2)); //false
//去除 nameVal 的前后空格. var reg = /^s*|s*$/g; nameVal = nameVal.replace(reg, "");
java:
String reward = "1:[1=3|2=1]:2:[44=3|54=3]:2"; String[] ss = reward.split(":\[|\]:|:"); ss = [1, 1=3|2=1, 2, 44=3|54=3, 2] reward = "1=1|2=1|3=1|4=1|5=1000"; String[] ss = reward.split("\|"); ss = [1=1, 2=1, 3=1, 4=1, 5=1000]