Java Code Examples for org.apache.commons.lang3.StringUtils.substringsBetween()

The following are Jave code examples for showing how to use substringsBetween() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: eds   File: ClientConfig.java   View Source Code Vote up 5 votes
public static String getProperty(String key) {
  String value = props.getProperty(key);
  if (value != null && value.contains("${") && value.contains("}")) {
    String[] vars = StringUtils.substringsBetween(value, "${", "}");
    if (vars != null && vars.length > 0) {
      for (String var : vars) {
        String varValue = System.getProperty(var, "");
        value = value.replace("${" + var + "}", varValue);
        LOG.info("eds-client.properties replace var: " + var + " => " + varValue);
      }
    }
  }
  return value;
}
 
Example 2
Project: phrase-java   File: TagProcessor.java   View Source Code Vote up 5 votes
private void findTagContent() {
	int startTags = StringUtils.countMatches(target, tag.getStartTag());
	int endTags = StringUtils.countMatches(target, tag.getEndTag());
	//make sure the amount of start and end tags are equal
	if(startTags == endTags) {
		String[] results = StringUtils.substringsBetween(target.toString(), tag.getStartTag().toString(), tag.getEndTag().toString());
		for(String result : results) {
			tagResult.addResult(result);
			logger.log("Found Tag: %s", result);
		}
	} else {
		//TODO: throw exception or something
		logger.log("Tag counts don't match. Found %s start tags and %s end tags!", startTags, endTags);
	}
}
 
Example 3
Project: Fetax-AI   File: XSSFilter.java   View Source Code Vote up 5 votes
private String rmXSSBetween(String script, final String open, final String close) {// 移除存在XSS攻击威胁的字符串

			String[] xss = StringUtils.substringsBetween(script, open, close);

			if (null != xss && xss.length > 0) {

				for (String xs : xss) {
					script = StringUtils.remove(script, open + xs + close);
					log.warn(open + xs + close + "已移除");
				}
			}

			return script;
		}
 
Example 4
Project: awe-awesomesky   File: XSSFilter.java   View Source Code Vote up 5 votes
private String rmXSSBetween(String script, final String open, final String close) {// 移除存在XSS攻击威胁的字符串

			String[] xss = StringUtils.substringsBetween(script, open, close);

			if (null != xss && xss.length > 0) {

				for (String xs : xss) {
					script = StringUtils.remove(script, open + xs + close);
					log.warn(open + xs + close + "已移除");
				}
			}

			return script;
		}
 
Example 5
Project: patternlab-for-sling   File: PatternPatternCategoryFactoryImpl.java   View Source Code Vote up 5 votes
private List<String> getTemplateDedicatedFiles(String templateName, List<String> jsonDataFiles, List<String> templateNames) {
    final List<String> templateDedicatedDataFiles = Lists.newArrayList();
    for (String jsonDataFile : jsonDataFiles) {
        final String[] jsonDataIds = StringUtils.substringsBetween(jsonDataFile, PatternLabConstants.SELECTOR, PatternLabConstants.SELECTOR);
        if (jsonDataIds == null || jsonDataIds.length == 0) {
            templateDedicatedDataFiles.add(jsonDataFile);
        } else {
            final String jsonDataId = jsonDataIds[0];
            if (StringUtils.equalsIgnoreCase(templateName, jsonDataId) || !templateNames.contains(jsonDataId)) {
                templateDedicatedDataFiles.add(jsonDataFile);
            }
        }
    }
    return templateDedicatedDataFiles;
}