我正在尝试使用 java regex 提取一个看起来像这样(如下)的字符串。
Automotive Vehicles (154949)
Cars (91364)
Auto Parts & Accessories (29987)
Motorcycles & Scooters (11648)
我尝试了以下方法:
for (Element link : links) {
String cat = link.text();
String pattern = "(\\w+\\w+?\\s?.?\\w+)";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(cat);
while (m.find( )) {
System.out.println("Category: "+m.group(0));
}
}