package com.zzsn.test;

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

public class test {

    public static void main(String[] args) {
        String a1="https://view.inews.qq.com/a/20211231A066QJ00";
        String a2="https://new.qq.com/omn/[date]/[pamars].html";
        String b1=a1.substring(a1.lastIndexOf("/")+1);
        String b2=getNumbers(b1);
        String c=a2.replace("[date]",b2).replace("[pamars]",b1);

    }
    //转换qq新闻链接
    public static String transURl(String oldurl){
        String patt="https://new.qq.com/omn/[date]/[pamars].html";
        String b1=oldurl.substring(oldurl.lastIndexOf("/")+1);
        String b2=getNumbers(b1);
        String curl=patt.replace("[date]",b2).replace("[pamars]",b1);
        return curl;
    }

    public static String getNumbers(String content) {

        Pattern pattern = Pattern.compile("\\d+");
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            return matcher.group(0);
        }
        return "";
    }
}
