我需要从“abc.xyz”格式的段落中读取一个字符串。我对正则表达式很陌生,我听不懂格式,请任何人帮助我获取数据示例:
Calendar_year_lookup.Yr、Outlet_Lookup.Shop_name、Article_lookup.Category、Article_lookup.Sale_price、sum(Shop_facts.Quantity_sold)
输出:
Calendar_year_lookup.Yr
Outlet_Lookup.Shop_name
Outlet_Lookup.Shop_name
Article_lookup.Sale_price
Shop_facts.Quantity_sold
代码:
public static void main(String[] args)
{
// TODO Auto-generated method stub
String data="Calendar_year_lookup.Yr,Outlet_Lookup.Shop_name,Article_lookup.Category, Article_lookup.Sale_price, sum(Shop_facts.Quantity_sold)";
//data.matches("\w\.\w");
Pattern pattern = Pattern.compile("\\p{L}+[.]\\p{L}+");
Matcher matchers=pattern.matcher(data);
//System.out.println(matchers);
if(matchers.find())
{
System.out.println(matchers.group(0));
}
}