正则解析


    public static String getMagazineType(String query)
    {
    	String queryObj = query.replaceFirst("SORTBY", "OR");
    	List<String> reStrList = new ArrayList<String>();
    	String [] queryList = queryObj.split("OR");
    	for (int i = 0; i < queryList.length; i++) 
    	{
    	    Pattern pattern = Pattern.compile("@SUP_MAGTYPE_ID[\\s]*=[\\s]*\"(.*?)\"");
    	    Matcher matcher = pattern.matcher(queryList[i]);
    	    if(matcher.find())
    	    {
    	    	reStrList.add(matcher.group(1));
    	    }   
    	}
    	if(reStrList.size()==0)
    	{
    		return "";
    	}
    	StringBuffer stringBuffer = new StringBuffer();
    	for (int i = 0; i < reStrList.size()-1; i++) {
    		stringBuffer.append(reStrList.get(i)+"','");
		}
    	stringBuffer.append(reStrList.get(reStrList.size()-1));
    	
    	return stringBuffer.toString();
    	       
    }


你可能感兴趣的:(ibatis,or)