摘要: 使用 localeCompare() 方法来进行字符串排序 let str = "qwertyuasdfghjzxcvbn"; str = [...str].sort((a,b)=>{ return a.localeCompare(b,"zh-CN") }).join("") console.log 阅读全文
posted @ 2021-08-03 13:33 Y-X南川 阅读(1096) 评论(0) 推荐(0) 编辑
摘要: @Test public void show(){ String s1 = "qwertyasdfghzxcvbn"; String s2 = myStrSort(s1); System.out.println(s2); //=> abcdefghnqrstvwxyz } public String 阅读全文
posted @ 2021-08-03 13:30 Y-X南川 阅读(1053) 评论(0) 推荐(0) 编辑
摘要: @Test public void testGetSomeStr() { String a = "sffioafihellosdfvasdf"; String b = "sfhellodesdfs"; String c = getSomeStr(a, b); System.out.println(c 阅读全文
posted @ 2021-08-03 13:29 Y-X南川 阅读(430) 评论(0) 推荐(0) 编辑
摘要: 方式一:使用 replace 的方式计算字符串出现次数 @Test public void show() { String s1 = "absfsdfabsdfosfabsfspfoj"; String s2 = "ab"; // 获取原始字符串的长度 int oldCount = s1.lengt 阅读全文
posted @ 2021-08-03 13:28 Y-X南川 阅读(10110) 评论(0) 推荐(1) 编辑
摘要: 方式一 @Test public void show() { String s1 = "abcdefg"; String s2 = "a"; // 先将需要翻转的字符串给截取出来 char[] chars = s1.substring(1, 6).toCharArray(); // 循环截取出来的字 阅读全文
posted @ 2021-08-03 13:26 Y-X南川 阅读(316) 评论(0) 推荐(0) 编辑
摘要: public class StringDemo1 { @Test public void show() { String s1 = " hello world sss "; String s2 = myTrim(s1); System.out.println(s2); //=> hello worl 阅读全文
posted @ 2021-08-03 13:22 Y-X南川 阅读(523) 评论(0) 推荐(0) 编辑