本文整理了Java中org.apache.commons.lang3.StringUtils.substringsBetween()
方法的一些代码示例,展示了StringUtils.substringsBetween()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.substringsBetween()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:substringsBetween
[英]Searches a String for substrings delimited by a start and end tag, returning all matching substrings in an array.
A null input String returns null. A null open/close returns null (no match). An empty ("") open/close returns null (no match).
StringUtils.substringsBetween("[a][b][c]", "[", "]") = ["a","b","c"]
StringUtils.substringsBetween(null, *, *) = null
StringUtils.substringsBetween(*, null, *) = null
StringUtils.substringsBetween(*, *, null) = null
StringUtils.substringsBetween("", "[", "]") = []
[中]在字符串中搜索由开始和结束标记分隔的子字符串,返回数组中所有匹配的子字符串。
空输入字符串返回空值。空的打开/关闭返回空(不匹配)。空(“”)打开/关闭返回null(不匹配)。
StringUtils.substringsBetween("[a][b][c]", "[", "]") = ["a","b","c"]
StringUtils.substringsBetween(null, *, *) = null
StringUtils.substringsBetween(*, null, *) = null
StringUtils.substringsBetween(*, *, null) = null
StringUtils.substringsBetween("", "[", "]") = []
代码示例来源:origin: ethereum/ethereumj
private static List<String> extractDependencies(String source) {
String[] deps = substringsBetween(source, "import \"", "\";");
return deps == null ? Collections.<String>emptyList() : asList(deps);
}
代码示例来源:origin: gocd/gocd
private void validateLabelTemplate() {
if (StringUtils.isBlank(labelTemplate)) {
addError("labelTemplate", BLANK_LABEL_TEMPLATE_ERROR_MESSAGE);
return;
}
String[] allTokens = substringsBetween(labelTemplate, "${", "}");
if (allTokens == null) {
addError("labelTemplate", String.format(LABEL_TEMPLATE_ERROR_MESSAGE, labelTemplate));
return;
}
for (String token : allTokens) {
if (!isValidToken(token)) {
break;
}
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
String[] results = StringUtils.substringsBetween("[one], [two], [three]", "[", "]");
assertEquals(3, results.length);
assertEquals("one", results[0]);
results = StringUtils.substringsBetween("[one], [two], three", "[", "]");
assertEquals(2, results.length);
assertEquals("one", results[0]);
assertEquals("two", results[1]);
results = StringUtils.substringsBetween("[one], [two], three]", "[", "]");
assertEquals(2, results.length);
assertEquals("one", results[0]);
assertEquals("two", results[1]);
results = StringUtils.substringsBetween("[one], two], three]", "[", "]");
assertEquals(1, results.length);
assertEquals("one", results[0]);
results = StringUtils.substringsBetween("one], two], [three]", "[", "]");
assertEquals(1, results.length);
assertEquals("three", results[0]);
results = StringUtils.substringsBetween("aabhellobabnonba", "ab", "ba");
assertEquals(1, results.length);
assertEquals("hello", results[0]);
results = StringUtils.substringsBetween("one, two, three", "[", "]");
assertNull(results);
代码示例来源:origin: CryptoWorldChain/ewallet
/**
* 返回所有在字符串str中从open开始到close结束的子字符串数组,引用org.apache.commons.lang.StringUtils.substringsBetween(String str,String open,String close)方法。<br>
* 如果str为null将返回null,如果open或close为null将返回null(没有匹配的),如果open和close为""将返回null(没有匹配的)。<br>
* 例:<br>
* StringUtil.substringsBetween("[a][b][c]", "[", "]") = ["a","b","c"] <br>
* StringUtil.substringsBetween(null, *, *) = null <br>
* StringUtil.substringsBetween(*, null, *) = null <br>
* StringUtil.substringsBetween(*, *, null) = null <br>
* StringUtil.substringsBetween("", "[", "]") = [] <br>
* @param str 包含子串的字符串(null将返回null,""将返回"")
* @param open 查找子字符串的开始位置(""将返回null)
* @param close 查找子字符串的结束位置(""将返回null)
* @return String 返回子字符串数组,如果没有匹配的返回null。
*/
public static String[] substringsBetween(String str,String open,String close){
return StringUtils.substringsBetween(str, open, close);
}
代码示例来源:origin: daniellitoc/xultimate-toolkit
/**
* <p>Searches a String for substrings delimited by a start and end tag,
* returning all matching substrings in an array.</p>
*
* <p>A {@code null} input String returns {@code null}.
* A {@code null} open/close returns {@code null} (no match).
* An empty ("") open/close returns {@code null} (no match).</p>
*
* <pre>
* StringUtils.substringsBetween("[a][b][c]", "[", "]") = ["a","b","c"]
* StringUtils.substringsBetween(null, *, *) = null
* StringUtils.substringsBetween(*, null, *) = null
* StringUtils.substringsBetween(*, *, null) = null
* StringUtils.substringsBetween("", "[", "]") = []
* </pre>
*
* @param str the String containing the substrings, null returns null, empty returns empty
* @param open the String identifying the start of the substring, empty returns null
* @param close the String identifying the end of the substring, empty returns null
* @return a String Array of substrings, or {@code null} if no match
* @since 2.3
*/
public static String[] substringsBetween(String str, String open, String close) {
return org.apache.commons.lang3.StringUtils.substringsBetween(str, open, close);
}
代码示例来源:origin: org.dashbuilder/dashbuilder-dataset-sql
public static List<String> getWordsBetweenQuotes(String s) {
List<String> result = new ArrayList<String>();
if (s != null) {
for (int i = 0; i < QUOTES.length; i++) {
String quote = QUOTES[i];
String[] words = StringUtils.substringsBetween(s, quote, quote);
if (words != null) {
result.addAll(Arrays.asList(words));
}
}
}
return result;
}
public static String changeCaseExcludeQuotes(String s, boolean upper) {
代码示例来源:origin: org.kie.soup/kie-soup-dataset-sql
public static List<String> getWordsBetweenQuotes(String s) {
List<String> result = new ArrayList<String>();
if (s != null) {
for (int i = 0; i < QUOTES.length; i++) {
String quote = QUOTES[i];
String[] words = StringUtils.substringsBetween(s, quote, quote);
if (words != null) {
result.addAll(Arrays.asList(words));
}
}
}
return result;
}
public static String changeCaseExcludeQuotes(String s, boolean upper) {
代码示例来源:origin: info.magnolia/magnolia-core
private static String[] getNamesBetweenPlaceholders(String propertiesFilesString, String contextNamePlaceHolder) {
final String[] names = StringUtils.substringsBetween(
propertiesFilesString,
PLACEHOLDER_PREFIX + contextNamePlaceHolder,
PLACEHOLDER_SUFFIX);
return StringUtils.stripAll(names);
}
代码示例来源:origin: com.haulmont.cuba/cuba-global
public static String formatName(String pattern, String firstName, String lastName, String middleName) throws ParseException {
if (pattern == null || pattern.length() == 0)
throw new ParseException("Pattern error", 0);
if (firstName == null || firstName.equals("null"))
firstName = "";
if (lastName == null || lastName.equals("null"))
lastName = "";
if (middleName == null || middleName.equals("null"))
middleName = "";
String[] params = StringUtils.substringsBetween(pattern, "{", "}");
int i;
for (i = 0; i < params.length; i++) {
pattern = StringUtils.replace(pattern, "{" + params[i] + "}", "{" + i + "}", 1);
params[i] = parseParam(params[i], firstName, lastName, middleName);
}
for (i = 0; i < params.length; i++) {
pattern = StringUtils.replace(pattern, "{" + i + "}", params[i], 1);
}
return pattern;
}
代码示例来源:origin: xixifeng/fastquery
String[] wheres = StringUtils.substringsBetween(str, openWhere, closeWhere);
if (wheres == null) {
return str;
代码示例来源:origin: heervisscher/htl-examples
String[] jsToBeMoved = StringUtils.substringsBetween(contents, BEGIN, END);
String modifiedContents = contents;
代码示例来源:origin: virjar/vscrawler
@Override
protected Strings handle(Strings input, StringContext stringContext, List<SyntaxNode> params) {
Preconditions.checkArgument(params.size() >= 2, "substringsBetween must has 2 parameters at lest");
Object openObject = params.get(1).calculate(stringContext);
if (!(openObject instanceof CharSequence)) {
throw new IllegalStateException(determineFunctionName() + " second parameter must bu string");
}
String closeString = openObject.toString();
if (params.size() >= 3) {
Object closeObject = params.get(2).calculate(stringContext);
if (!(closeObject instanceof CharSequence)) {
throw new IllegalStateException(determineFunctionName() + " second parameter must bu string");
}
closeString = closeObject.toString();
}
Strings ret = new Strings();
for (String str : input) {
Collections.addAll(ret, StringUtils.substringsBetween(str, openObject.toString(), closeString));
}
return ret;
}
代码示例来源:origin: org.kuali.common/kuali-util
/**
* Return a new <code>Properties</code> object loaded from <code>location</code> where the properties are stored in Rice XML style syntax
*
* @deprecated use loadRiceProps() instead
*/
@Deprecated
public static final Properties loadRiceProperties(String location) {
logger.info("Loading Rice properties [{}] encoding={}", location, DEFAULT_XML_ENCODING);
String contents = LocationUtils.toString(location, DEFAULT_XML_ENCODING);
String config = StringUtils.substringBetween(contents, "<config>", "</config>");
String[] tokens = StringUtils.substringsBetween(config, "<param", "<param");
Properties properties = new Properties();
for (String token : tokens) {
String key = StringUtils.substringBetween(token, "name=\"", "\">");
validateRiceProperties(token, key);
String value = StringUtils.substringBetween(token + "</param>", "\">", "</param>");
properties.setProperty(key, value);
}
return properties;
}
代码示例来源:origin: org.xworker/xworker_core
public static String[] substringsBetween(ActionContext actionContext){
Thing self = actionContext.getObject("self");
String str = (String) self.doAction("getStr", actionContext);
String open = (String) self.doAction("getOpen", actionContext);
String close = (String) self.doAction("getClose", actionContext);
return StringUtils.substringsBetween(str, open, close);
}
代码示例来源:origin: com.netflix.spinnaker.halyard/halyard-config
List<String> tokens = Arrays.asList(StringUtils.substringsBetween(resolvedUserData, "%%", "%%"));
List<String> invalidTokens = tokens.stream()
.filter(t -> !validTokens.contains(t))
代码示例来源:origin: spinnaker/halyard
List<String> tokens = Arrays.asList(StringUtils.substringsBetween(resolvedUserData, "%%", "%%"));
List<String> invalidTokens = tokens.stream()
.filter(t -> !validTokens.contains(t))
内容来源于网络,如有侵权,请联系作者删除!