public class SimpleTest { @Test public void test() { String s = "https://www.baidu.comhttp://abc.com/abc.jpg"; Matcher matcher = Pattern.compile("https?://.+").matcher(s); while (matcher.find()) { System.out.println(matcher.group()); } } } 如上代码, 我想把字符串分割成两个正确的 url, 可是上面的正则始终是"贪婪模式", 一下子匹配到整个字符串.
如果正则写成 https?://.+?, 又只会匹配到如下结果:
- https://w
- http://a
有没有帅气堪比吴彦祖的朋友解答一下我的疑惑呀
