1:OCR读取出来的身份证地址字符串切割为省、市、区/县、详细地址
2:切割工具:
public class AddressSubUtils {
/**
* 切割地址字符串
* @param addr
* @return
*/
public static Map<String,Object> getAddress(String addr){
Map<String,Object> map = new HashMap();
String city =null;
String province = null;
String district=null;
String are = null;
String regex1="(?<province>[^自治区]+自治区|[^省]+省|[^市]+市)";
Matcher m1 = Pattern.compile(regex1).matcher(addr);
while (m1.find()){
province = m1.group("province");
if(province != null){
addr=addr.replaceFirst(province,"");
break;
}
}
String regex2="(?<city>[^辖区]+辖区|[^盟]+盟|[^自治州]+自治州|[^地区]+地区|[^市]+市|.+区划)";
Matcher