第一次发现JavaScript中replace() 方法如果直接用str.replace("-","!") 只会替换第一个匹配的字符. 而str.replace(/\-/g,"!")则可以全部替换掉匹配的字符(g为全局标志). replace() The replace() method returns the string that results when you replace text matching its first argum
题目: 比如输入为aaabbc,输出a3b2c1 完整解答: public class Other { static String func(String str) { StringBuffer result = new StringBuffer(); if (str.length() == 1) { result.append(str.charAt(0)); result.append('1'); return result.toString(); } else { // string len
function getCaption(obj){ var index=obj.lastIndexOf("\-"); obj=obj.substring(index+1,obj.length); // console.log(obj); return obj; } var str=" 执法办案流程-立案审批"; getCaption(str);
可对照查看网盘ASCII表http://yunpan.cn/cyxg4wQjQaGEQ (提取码:8b29) public static void main(String[] args) { // // TODO Auto-generated method stub int a=001; int b=32;//制表符 int c=13;//回车键 char character = (char)a; char cb = (char)b; String line ="niaho" + ch