0
String s="For the AWSDataTransfer product, this is the public pricing plan";

如何在 JDK 中使用 REGEX提取(和AWSDataTransfer之间的单词)?theproduct

4

1 回答 1

4

像这样:

String s="For the AWSDataTransfer product, this is the public pricing plan";
Pattern pattern = Pattern.compile("the\\s(.+?)\\sproduct");
Matcher matcher = pattern.matcher(s);
if (matcher.find()) {
    System.out.println(matcher.group(1));
}

输出:

AWSDataTransfer
于 2013-06-11T21:17:18.040 回答