查找字符串中的字符 在字符串:/lks/koa/lks_news.nsf/VD_Portlet_View?ReadViewEntries&PreFormat&Count=2&RestrictToCategory=%u516C%u53F中,怎么找到Count=2这个字符呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int index=indexOf("Count=2"); 我是要找到后还要改变Count=2 的值 比如把2 改成3 单独的String的话!public class test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String str = "===Count=2=="; int ind = str.indexOf("Count=2"); if (ind != -1) { str = str.substring(ind, ind + 7); } System.out.println(str); }}(2)如果是url的话!我们可以用request.getparameter(Count) 用str.replaceFirst("Count=2", "Count=3");或者其他的方法看需求了!public class test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String str = "===Count=2=="; String strRet = ""; int ind = str.indexOf("Count=2"); if (ind != -1) { strRet = str.substring(ind, ind + 7); str = str.replaceFirst("Count=2", "Count=3"); } System.out.println(str); }} String strcount = "/lks/koa/lks_news.nsf/VD_Portlet_View?ReadViewEntries&PreFormat&Count=2&RestrictToCategory=%u516C%u53F";String str = "Count=2";int index = strcount.indexOf(str);if (index>=0){str = "Count=3";int ind = strcount.indexOf(str);} indexOf()是查找他的位置吗 Count=2这个2是一个变量。我怎么把我是要修改的 import java.util.regex.Matcher;import java.util.regex.Pattern;public class Test2 { public static void main(String[] args) { String strcount = "/lks/koa/lks_news.nsf/VD_Portlet_View?" + "ReadViewEntries&PreFormat&Count=2&" + "RestrictToCategory=%u516C%u53F"; Pattern pattern = Pattern.compile("(&Count\\=)\\d+(&)"); Matcher matcher = pattern.matcher(strcount); matcher.find(); int modify = 3; strcount = strcount.substring(0, matcher.end(1)) + modify + strcount.substring(matcher.start(2)); System.out.println(strcount); }} 使用JDBC获取Oracle的number类型字段报错 请问JAVA桌面程序怎么在启动时最小化到托盘?? 一个关于java io的问题 jbuilder用Native 生成exe时遇到的问题,求解. 网络通讯问题,紧急着用!请各位高手帮帮忙!谢谢 HelloWorld没调试出来,同情一下 如何取得字体名 MySql的驱动程序问题!(在线等待) 如何在类中处理中文字符的分行显示? 刚才发现了一个很严重的问题,java传递参数的时候不能检查正确? java程序的问题,请教高手 为什么创建不了数据源呢?(要用在连接sql server数据时),在线急盼!
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "===Count=2=="; int ind = str.indexOf("Count=2");
if (ind != -1) {
str = str.substring(ind, ind + 7);
}
System.out.println(str);
}}(2)如果是url的话!我们可以用request.getparameter(Count)
或者其他的方法看需求了!
public class test { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "===Count=2==";
String strRet = ""; int ind = str.indexOf("Count=2");
if (ind != -1) {
strRet = str.substring(ind, ind + 7);
str = str.replaceFirst("Count=2", "Count=3");
}
System.out.println(str);
}}
";
String str = "Count=2";int index = strcount.indexOf(str);
if (index>=0)
{
str = "Count=3";
int ind = strcount.indexOf(str);
}
是查找他的位置吗
这个2是一个变量。我怎么把我是要修改的
import java.util.regex.Pattern;public class Test2 {
public static void main(String[] args) {
String strcount = "/lks/koa/lks_news.nsf/VD_Portlet_View?" +
"ReadViewEntries&PreFormat&Count=2&" +
"RestrictToCategory=%u516C%u53F";
Pattern pattern = Pattern.compile("(&Count\\=)\\d+(&)");
Matcher matcher = pattern.matcher(strcount);
matcher.find();
int modify = 3;
strcount = strcount.substring(0, matcher.end(1)) + modify +
strcount.substring(matcher.start(2));
System.out.println(strcount);
}
}