正则处理String - yiyixiaozhi/readingNotes GitHub Wiki

正则处理String

删除字符串中开头为0的部分:

String str = "0753681474";
String s = str.replaceAll("^[0]*", "");
System.out.println(s); // 753681474

匹配几行,末尾用固定文字

checkIfUserCanPassDevice\n[^\n]+\n[^\n]+\n[^\n]+\n[^\n]+\n[^\n]+48686

2019-09-02 18:07:22.155  INFO 13564 --- [nio-8085-exec-2] link.yyxz.base.HttpAspect            : startRunMethond: link.yyxz.controller.DeviceController.checkIfUserCanPassDevice
2019-09-02 18:07:22.155 DEBUG 13564 --- [nio-8085-exec-2] l.q.d.L.listByDeviceId                   : ==>  Preparing: select tlc.* from t_location_code as tlc, t_device as td where td.id = ? and td.location_code_id = tlc.id 
2019-09-02 18:07:22.155 DEBUG 13564 --- [nio-8085-exec-2] l.q.d.L.listByDeviceId                   : ==> Parameters: 209(Long)
2019-09-02 18:07:22.156 DEBUG 13564 --- [nio-8085-exec-2] l.q.d.L.listByDeviceId                   : <==      Total: 1
2019-09-02 18:07:22.156 DEBUG 13564 --- [nio-8085-exec-2] l.q.d.R.listDeptIdsByUserId              : ==>  Preparing: select dept_id from rel_user_dept where user_id = ? 
2019-09-02 18:07:22.156 DEBUG 13564 --- [nio-8085-exec-2] l.q.d.R.listDeptIdsByUserId
⚠️ **GitHub.com Fallback** ⚠️