大侠们我有这样一个需求:标示符 identifier:(/news/|/finace/)&from=ucweb
链接 URL : /news/abroad/zhuanti?nid=122334&from=ucweb&foo=sthelse求解URL是否匹配identifier?我的思路是以 (, ) , | , &四个字符分解标示符,然后计算分别计算/news/, /finance/, from=ucweb的布尔值,然后根据运算顺序求最终布尔值。但是不知道该如何实现,或许可以借鉴数学运算的原理,哪位高人可以指点一下?非常感谢!
链接 URL : /news/abroad/zhuanti?nid=122334&from=ucweb&foo=sthelse求解URL是否匹配identifier?我的思路是以 (, ) , | , &四个字符分解标示符,然后计算分别计算/news/, /finance/, from=ucweb的布尔值,然后根据运算顺序求最终布尔值。但是不知道该如何实现,或许可以借鉴数学运算的原理,哪位高人可以指点一下?非常感谢!
System.out.println("/news/abroad/zhuanti?nid=122334&from=ucweb&foo=sthelse".matches(regex));
System.out.println("/news/?from=ucweb&foo=sthelse".matches(regex));
System.out.println("/news/abroad/zhuanti?nid=122334&from=ucweb".matches(regex));
System.out.println("/news/abroad/zhuanti?nid=122334&from=ucweb#anchor".matches(regex));
System.out.println("/news/abroad/zhuanti?nid=122334&xfrom=ucwebtt".matches(regex));
System.out.println("/news/abroad/zhuanti?nid=122334&xfrom=ucweb".matches(regex));
System.out.println("/news/abroad/zhuanti?nid=122334&from=ucwebtt".matches(regex));
System.out.println("/news/abroad/zhuanti?xfrom=ucweb".matches(regex));
System.out.println("/news/abroad/zhuanti?from=ucwebtt".matches(regex));
String regex = "/(news|finance)/.*?[&]from=ucweb([&].*)?";