package cn.qaiu.util; import org.junit.Test; import java.util.regex.Matcher; import java.util.regex.Pattern; public class TestRegex { @Test public void regexYFC() { String html = """ true|
"""; Pattern compile = Pattern.compile("href=\"([^\"]+)\""); Matcher matcher = compile.matcher(html); if (matcher.find()) { // System.out.println(matcher.group(0)); System.out.println(matcher.group(1)); } } @Test public void testYeShareKey() { String url = "ABCD1234-asdasd"; String shareKey = url.replaceAll("(\\..*)|(#.*)", ""); System.out.println(shareKey); url = "ABCD1234-adasd.html"; shareKey = url.replaceAll("(\\..*)|(#.*)", ""); System.out.println(shareKey); url = "ABCD1234-adasd#123123"; shareKey = url.replaceAll("(\\..*)|(#.*)", ""); System.out.println(shareKey); url = "ABCD1234-adasd.html#123123"; shareKey = url.replaceAll("(\\..*)|(#.*)", ""); System.out.println(shareKey); } }