eight
2024-08-22 4ec8c306229e53951c7cb445f027d3b37f47f742
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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));
        }
    }
}