Java Code Examples for org.apache.commons.lang3.StringUtils#replaceAll()
The following examples show how to use
org.apache.commons.lang3.StringUtils#replaceAll() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-boot-start-current File: RequestLoggingFilter.java License: Apache License 2.0 | 6 votes |
@Override public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException, ServletException { if ( PatternMatchUtils.simpleMatch( excludeUrlPatterns , ( ( HttpServletRequest ) request ).getRequestURI() ) ) { chain.doFilter( request , response ); return; } final BodyReaderWrapper wrapper = new BodyReaderWrapper( ( HttpServletRequest ) request ); String requestMessage = RequestUtils.getRequestMessage( wrapper ); if ( ! LogUtils.getLogger().isDebugEnabled() ) { requestMessage = StringUtils.replaceAll( requestMessage , PASSWORD_FILTER_REGEX , "enable password protection, if not debug so do not see" ); } LogUtils.getLogger().info( requestMessage ); chain.doFilter( wrapper , response ); }
Example 2
Source Project: SENS File: PostController.java License: GNU General Public License v3.0 | 5 votes |
/** * 去除html,htm后缀,以及将空格替换成- * * @param url url * @return String */ private static String urlFilter(String url) { if (null != url) { final boolean urlEndsWithHtmlPostFix = url.endsWith(".html") || url.endsWith(".htm"); if (urlEndsWithHtmlPostFix) { return url.substring(0, url.lastIndexOf(".")); } } return StringUtils.replaceAll(url, " ", "-"); }
Example 3
Source Project: weixin-java-tools File: DataUtils.java License: Apache License 2.0 | 5 votes |
/** * 将数据中包含的secret字符使用星号替换,防止日志打印时被输出 */ public static <E> E handleDataWithSecret(E data) { E dataForLog = data; if(data instanceof String && StringUtils.contains((String)data, "&secret=")){ dataForLog = (E) StringUtils.replaceAll((String)data,"&secret=\\w+&","&secret=******&"); } return dataForLog; }
Example 4
Source Project: spring-boot-start-current File: DefaultInjectionAttackHandler.java License: Apache License 2.0 | 5 votes |
@Override public String filterSqlInjection ( String rawCharacters ) { if ( StringUtils.isBlank( rawCharacters ) ) { return rawCharacters; } return StringUtils.replaceAll( rawCharacters , SQL_INJECTION_REGEX , StringUtils.EMPTY ); }
Example 5
Source Project: spring-boot-start-current File: DefaultInjectionAttackHandler.java License: Apache License 2.0 | 5 votes |
@Override public String filterXSSInjection ( String rawCharacters ) { if ( StringUtils.isBlank( rawCharacters ) ) { return rawCharacters; } return StringUtils.replaceAll( rawCharacters , XSS_REGEX , StringUtils.EMPTY ); }
Example 6
Source Project: spring-boot-start-current File: DefaultInjectionAttackHandler.java License: Apache License 2.0 | 5 votes |
@Override public String filterSpecialCharacters ( String rawCharacters ) { if ( StringUtils.isBlank( rawCharacters ) ) { return rawCharacters; } return StringUtils.replaceAll( rawCharacters , SPECIAL_CHARACTERS_REGEX , StringUtils.EMPTY ); }
Example 7
Source Project: studio File: FindAndReplaceUpgradeOperation.java License: GNU General Public License v3.0 | 5 votes |
@Override protected void updateFile(final String site, final Path path) throws UpgradeException { String content = readFile(path); String updated = null; if(StringUtils.isNotEmpty(content)) { updated = StringUtils.replaceAll(content, pattern, replacement); } if(StringUtils.isNotEmpty(updated) && !StringUtils.equals(content, updated)) { logger.info("Updating file {0}", path); writeFile(path, updated); } }
Example 8
Source Project: julongchain File: Utils.java License: Apache License 2.0 | 4 votes |
public static void replaceFileContent(String filePath, String oldStr, String newStr) throws IOException { String string = FileUtils.readFileToString(new File(filePath), Charset.forName("UTF-8")); string = StringUtils.replaceAll(string, oldStr, newStr); FileUtils.writeStringToFile(new File(filePath), string, Charset.forName("UTF-8")); }
Example 9
Source Project: smockin File: GeneralUtils.java License: Apache License 2.0 | 4 votes |
public static String removeAllLineBreaks(final String original) { return StringUtils.replaceAll(original, System.getProperty("line.separator"), ""); }
Example 10
Source Project: cyberduck File: DAVRedirectStrategy.java License: GNU General Public License v3.0 | 4 votes |
@Override protected URI createLocationURI(final String location) throws ProtocolException { return super.createLocationURI(StringUtils.replaceAll(location, " ", "%20")); }
Example 11
Source Project: bird-java File: PoiExcelHelper.java License: MIT License | 4 votes |
/** * 读取每一行的数据 * * @param row 行数据 * @param headKeys keys * @param evaluator 公式计算器 * @return 行数据 */ private static Map<String, Object> readLine(Row row, List<String> headKeys, FormulaEvaluator evaluator) { if (row == null) return null; Map<String, Object> line = new HashMap<>(8); short max = row.getLastCellNum(); for (short i = row.getFirstCellNum(); i < max; i++) { if (i >= headKeys.size()) break; Cell cell = row.getCell(i); if (cell == null) continue; String key = headKeys.get(i); Object value = null; CellType cellType = cell.getCellTypeEnum(); switch (cellType) { case STRING: value = StringUtils.replaceAll(cell.getStringCellValue(),"^\\s*|\\s*$|\t|\r|\n",""); break; case NUMERIC: if (HSSFDateUtil.isCellDateFormatted(cell)) { value = HSSFDateUtil.getJavaDate(cell.getNumericCellValue()); } else { value = cell.getNumericCellValue(); } break; case BOOLEAN: value = cell.getBooleanCellValue(); break; case FORMULA: CellValue cellValue = evaluator.evaluate(cell); value = cellValue.getCellTypeEnum() == CellType.NUMERIC ? cellValue.getNumberValue() : cellValue.getStringValue(); break; default: break; } if (value != null && Objects.equals(value.getClass().getName(), "java.lang.Double") && StringUtils.indexOf(value.toString(), "E") >= 0) { value = DECIMAL_FORMAT.format(value); } line.put(key, value); } return line; }
Example 12
Source Project: vscrawler File: ReplaceAll.java License: Apache License 2.0 | 4 votes |
@Override protected String handle(String input, String second, String third) { return StringUtils.replaceAll(input, second, third); }
Example 13
Source Project: onos File: MappingStoreTypeCompleter.java License: Apache License 2.0 | 4 votes |
private String removeMapPrefix(String type) { return StringUtils.replaceAll(type, MAP_PREFIX, ""); }
Example 14
Source Project: kbase-doc File: HtmlUtils.java License: Apache License 2.0 | 2 votes |
/** * 将 data 中的编码修改为 utf-8 * @author eko.zhan at 2017年8月11日 上午9:54:34 * @param data * @return */ public static String replaceCharset(String data){ return StringUtils.replaceAll(data, "(?i)CONTENT=\"text/html; charset=gb2312\"", "CONTENT=\"text/html; charset=utf-8\""); }
Example 15
Source Project: DBus File: ZkService.java License: Apache License 2.0 | 2 votes |
/** * 获得当前值 * * @param path * @return * @throws Exception */ @Override public List<String> getChildren(String path) throws Exception { path = StringUtils.replaceAll(path, "//", "/"); return client.getChildren().forPath(path); }