打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
String中文字替换<递归算法>

String中文字替换<递归算法>

private static String resSql = "";

     /**

      * @param 替换sql 语句中以startWith开头, endWith结尾的String 并且得到中间的String

      * @sql 进行替换的String

      * @startWith  XX开头

      * @endWith    XX结尾

      * @replaceWith  替换成文字

      * */

     private static StringreplaceParams(String sql, String startWith,

           String endWith, String replaceWith) {

       resSql = sql;

       List<String> paramList = new ArrayList<String>();

       if (sql.indexOf(startWith, 0) > 0) {

           int startNUm = resSql.indexOf(startWith, 0);

           int endNum = resSql.indexOf(endWith, startNUm);

           String paramName = resSql.substring(startNUm, endNum);

           paramName = paramName.substring(1, paramName.length());

           paramList.add(paramName);

           resSql = resSql.replace(startWith + paramName + endWith,

                  replaceWith);

       } else

           resSql = "";

       if (resSql.indexOf(startWith) > 0)

           replaceParams(resSql, "{", "}", "?");

       return resSql;

    }

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
C#.NET操作数据库通用类(MS SQL Server篇)
C#通过StartWith和EndWith方法判断字符串是否以特定字符开始或者结束
查询分页的几种Sql写法
.net网页开发中的三层架构
HibernateTemplate常用方法总结
Indexof(string xx)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服