You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
569 B
27 lines
569 B
package com.platform.test;
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class TestPattern {
|
|
|
|
@Test
|
|
public void test1Pattern() {
|
|
String s = "e/FTP_GFS_point/320404_49/321311_215/320100_4/1/";
|
|
|
|
// 末尾 含有 /
|
|
Pattern pattern2 = Pattern.compile("\\d+\\/$");
|
|
Matcher matcher2 = pattern2.matcher(s);
|
|
//去掉 最后 的 数字 +/ 符合
|
|
if (matcher2.find()) {
|
|
String removeStr = matcher2.group();
|
|
s = s.replace(removeStr, "");
|
|
}
|
|
System.out.println(s);
|
|
|
|
}
|
|
|
|
}
|