2007年10月5日 星期五

StringUtils 使用subStringBetween

package com.test;
import org.apache.commons.lang.StringUtils;

/**
*
* @author macbook
*/
public class splitString {


public String substringBetween(String var,String open ,String close,String d4 ){
return StringUtils.isBlank(StringUtils.substringBetween(var, open, close))?d4:StringUtils.substringBetween(var, open, close);
}

public String splitLeft(String var){
return StringUtils.substringBetween(var, "(", ",");
}


public String splitLeft(String var ,String d4){
return StringUtils.isBlank(this.splitLeft(var))?d4:this.splitLeft(var);
}

public static void main(String[] arg){
splitString s = new splitString();
System.out.println(s.splitLeft("(,)", "--"));
System.out.print(s.substringBetween("(20070401,)", ",", ")", "--"));

}
}

沒有留言: