URL匹配
思路:
1.先验证url开始部分 https:// 或 http://
2.通过((http|https)😕/)([\w-]+.)+[\w$]+ 匹配域名
3.(/[\w-?=&./]*)? 匹配 /video/BV1Eq4y1E79W?from=search&seid
public class RegExp11 {public static void main(String[] args){String content = "/video/BV1Eq4y1E79W?from=search&seid=9946545262871408175";//思路:// 1.先验证url开始部分 https:// 或 http://// 2.通过((http|https)://)([\w-]+\.)+[\w$]+ 匹配域名// 3.(\/[\w-?=&./]*)? 匹配 /video/BV1Eq4y1E79W?from=search&seidString regStr = "^((http|https)://)([\\w-]+\\.)+[\\w$]+(\\/[\\w-?=&./]*)?$";//[.?*]表示匹配的就是本身Pattern pattern = pile(regStr);Matcher matcher = pattern.matcher(content);if (matcher.find()){System.out.println("满足格式!");}else {System.out.println("不满足格式!");}}}