//向后匹配

String a = "I paid $90 for 10 oranges, 12 pears and 8 apples. I saved $5 on ";
Pattern p = Pattern.compile("(?<=\\$)\\d+");
Matcher m = p.matcher(a);
while (m.find ())
{
String group = m.group ();
System.out.println (group);
}

向前匹配
a = "https://mail.huawei.com ";
p = Pattern.compile(".+(?=:)");
m = p.matcher(a);
while (m.find ())
{
String group = m.group ();
System.out.println (group);
}

相关文章:

  • 2021-06-06
  • 2022-12-23
  • 2021-09-21
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
相关资源
相似解决方案