多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 组件源码 ``` /** * <b>方法描述:</b> 字符串替换 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-08 18:16:26 <br/> * * @param text * 入参|字符串|{@link java.lang.String} * @param searchString * 入参|被替换字符|{@link java.lang.String} * @param replacement * 入参|替换字符|{@link java.lang.String} * @param max * 入参|替换次数|{@link int} * @return -1 异常<br/> * 1 成功<br/> */ @Component(label = "字符串替换", style = "判断型", type = "同步组件", comment = "输入字符串中指定的字符按照规则替换成新字符串,max为小于0是全部替换", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-08 06:16:26") @InParams(param = { @Param(name = "text", comment = "字符串", type = java.lang.String.class), @Param(name = "searchString", comment = "被替换字符", type = java.lang.String.class), @Param(name = "replacement", comment = "替换字符", type = java.lang.String.class), @Param(name = "max", comment = "替换次数", type = int.class) }) @OutParams(param = { @Param(name = "newStr", comment = "替换后字符串", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_replace(String text, String searchString, String replacement, int max) { if (max < 1) max = -1; try { return ResultBase.newSuccessResult(StringUtil.replace(text, searchString, replacement, max)); } catch (Exception e) { AppLog.error("字符串替换异常,原字符串:{},被替换字符串:{},替换字符串:{},替换次数:{}", text, searchString, replacement, max); AppLog.error(e); } return ResultBase.newExceptionResult("TPTS1014", "参数错误,不能替换"); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/0b/0f/0b0f53c8f21e7ad2fb76bed894b1ed5f_1868x891.png) # 参数说明及示例 ## 入口参数 字符串:输入字符串,示例: `"你好,世界22333"` 被替换字符:输入字符,示例: `"2"` 替换字符:输入字符,示例: `"3"` 替换次数:需要替换几次,小于 0 是全部替换,示例: `2` ## 出口参数 替换后字符串:输入字符串中指定的字符按照规则替换成新字符串,示例: `__INNER__["result"]`