首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

查寻某个字符在字符串中的各个位置记录

2012-09-01 
查找某个字符在字符串中的各个位置记录?? ? ? ? ? ? ? ?//查找某个字符在字符串中的各个位置记录String sq

查找某个字符在字符串中的各个位置记录

?

? ? ? ? ? ? ? ?//查找某个字符在字符串中的各个位置记录

String sql = " SELECT 1 FROM DUAL WHERE 1=1 AND 2=2 {AND ny = $1} { AND org_no = $2}";

int count = StringUtils.countMatches(sql, "{");

int[] indexs = new int[count];

? ? ? ? int index = 0;

? ? ? ? for(int idx = 0; (idx = sql.indexOf("{", idx)) != -1; idx += "{".length()){

? ?? ?indexs[index++] = idx;

??}

? ? ? ? for(int i:indexs){

? ?? ?System.out.println("----------- index = " + i);

? ? ? ?}

?

?

热点排行