package com.ms.biz.test;

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

public class ParseUrlTest {
    public static void main(String[] args) {
        String url = "https://detail.1688.com/offer/1170150484.html?spm=a2638t.27033214.reofferlist.3.3836436cs3Sfb7&cosite=-&ilike_session=be0662f0477043b5a18fa1c387874546&tracelog=p4p&_p_isad=1&clickid=be0662f0477043b5a18fa1c387874546&sessionid=83661dcc6244135f10a5399fceda54a1";
        Pattern pattern = Pattern.compile("(.*\\.1688\\.com\\/(?:offer|pic)\\/|caigou\\.1688\\.com\\/detail\\/)(?<id>\\d+).(htm|html)", Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(url);
        if (matcher.find()) {
            System.out.println(matcher.group("id"));  // 输出: 1170150484
        }
    }
}
