String s="For the AWSDataTransfer product, this is the public pricing plan";
如何在JDK中使用REGEX提取AWSDataTransfer
(the
和product
之间的单词)?
答案 0 :(得分: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