package cn.lihu.jh.module.ecg.service.appointment; import cn.lihu.jh.module.ecg.controller.admin.appointment.vo.*; import cn.lihu.jh.module.ecg.dal.dataobject.appointment.AppointmentDO; import cn.lihu.jh.module.ecg.dal.mysql.appointment.AppointmentMapper; import cn.lihu.jh.framework.common.pojo.PageResult; import org.junit.Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import javax.annotation.Resource; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * {@link AppointmentServiceImpl} 的单元测试类 * * @author 马剑波 */ @SpringBootTest public class AppointmentServiceImplTest { @Resource private AppointmentServiceImpl appointmentService; @Resource private AppointmentMapper appointmentMapper; @Test public void test() { String regex = "(\\d+)[::](\\d+)"; String input = "08:00"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(input); if (matcher.find()) { // 获取整个匹配的字符串 String fullMatch = matcher.group(); System.out.println("Full match: " + fullMatch); // 获取第一个捕获组(用户名) String username = matcher.group(1); System.out.println("Username: " + username); System.out.println("Username: " + Integer.valueOf(username)); // 获取第二个捕获组(域名) String domain = matcher.group(2); System.out.println("Domain: " + domain); System.out.println("Domain: " + Integer.valueOf(domain)); } } }