编辑代码

import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
    public static void main(String[] args) {
        // 被测试内容
        String str = "https://jsrun.net/xx/x/p/1111.html\n "+
         "https://jsrun.net/ysw-go/440.html\n"+
         "https://jsrun.net/ysw-go/p/666666.html 你好吗?";

        // 正则表达式
        String reg = "https://jsrun.net/([a-zA-Z0-1\\-]*)/p/(\\d*).html";

        //修改上方正则表达式和测试内容点击运行就可以在线进行测试, 也可想根据需要修改下方代码


        Matcher m1 = Pattern.compile(reg).matcher(str);
        String lines="";
        int count=0;
        while (m1.find()) { 
            lines+=m1.group() +"\n"; 
            count++;
        }  
        if(count>0) {
            System.out.println("找到"+count+"个相匹配结果:");
            System.out.println(lines); 
        } else {
            System.out.println("未找到相匹配结果");
        }
    }
}