有一个不定长变量如下:
“...and year>=2010 and month>=07 and year>=2010 and month>=07 ”,其中前面的...代表还有其它字符,具体长度不定。我希望得到的结果是:“...and year>=2010 and month>=07 and year=和month>=出现两次,那么就把后面出现的>=换成=2010 and year>=2010 and month>=07 ”,就要得到“...and year>=2010 and year=07 ”.
这个算法想的我头疼,可能解决办法并不复杂,望达人指点迷津,不胜感激!
不理解你为什么要解决这样的问题。大概的代码如下:
String s = "...and year>=2010 and month>=07 and year>=2010 and month>=07 ";
public String convertString(String s) {
StringTokenizer st = new StringTokenizer(s);
int counterYear = 0;
int counterMonth = 0;
String tmpStr = "";
String result = "";