有固定的前后节点规定么??
用substring()也许可以。循环也可以。
用substring()也许可以。循环也可以。
解决方案 »
- cms发布的网站如何添加功能?
- 各位哥哥姐姐别闲分少 我把分都给你们了 我很着急。 !
- 在线讨论一个b/s架构的问题(高手请进)
- 一段代码,有个不明白的地方,望高手解析。
- 包含有N个字段的表单内容保存更新操作大家一般实现方案是怎么样的?
- 一个struts action问题
- 想学习servlet,请大家推荐几本好书
- 如何取得小数点的前三位?在线等!!!
- 能否介绍几个JSP的技术群?谢谢!
- org.apache.jasper.JasperException: getOutputStream() has already been called for this response
- 同样的代码为什么不能在表中插入数据
- 请教一个sessionbean的问题
public String bbc(String strValue, String chrValue) {
String str_Value = strValue;
String car_Value = chrValue;
String strTmp="";
String str_return = "none";
int isave,icount, i;
isave = 0;
try {
icount = str_Value.length();
while (isave < icount) {
if (strValue.indexOf(chrValue, isave) != -1) {
if (strValue.substring(isave, isave+2)=="12"){
str_return=strValue.substring(isave, isave+2);
return str_return;
}
}
}
}
catch (Exception e) { }
return str_return;
}
public String bbc(String strValue, String chrValue) {
String str_Value = strValue;
String chr_Value = chrValue;
String strTmp="";
String str_return = "none";
int isave,icount;
isave = 0;
try {
icount = str_Value.length();
while (isave < icount) {
if (str_Value.indexOf(chr_Value, isave) != -1) {
if (str_Value.substring(isave, isave+2)=="12"){
str_return=str_Value.substring(isave, isave+2);
return str_return;
}
}
}
}
catch (Exception e) { }
return str_return;
}
String result=s.substring(s.indexOf("需要")+4,s.indexOf("分钟"));
如果你要得到int型的
int i=Integer.parseInt(result);
由于我要处理的字符串中有没有数字是不确定的,我编了一个方法,请批评指正.
public int getNumber(String str){
int num = -1;
char charTemp;
String strTemp = "";
char charNum[] = new char[20];
int ascValue = 0;
int p = 0; for(int i=str.length()-1;i>=0;i--){
charTemp = str.charAt(i);
ascValue = (int)charTemp;
if(((ascValue>=48)&&(ascValue<=57))||((ascValue>=65296)&&(ascValue<=65305))){
charNum[i]=charTemp;
p=i;
}
else{
if(p==i+1){
break;
}
}
}
for(int j=0;j<charNum.length;j++){//int j=charNum.length-1;j>=0;j--){
if(charNum[j]!='\u0000'){
strTemp = strTemp.concat(new Character(charNum[j]).toString());
}
}
if(strTemp.length()>0){
num = Integer.parseInt(strTemp);
}
return num;
}