本文整理了Java中org.apache.commons.lang3.StringUtils.lastIndexOfIgnoreCase()
方法的一些代码示例,展示了StringUtils.lastIndexOfIgnoreCase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.lastIndexOfIgnoreCase()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:lastIndexOfIgnoreCase
[英]Case in-sensitive find of the last index within a CharSequence.
A null CharSequence will return -1. A negative start position returns -1. An empty ("") search CharSequence always matches unless the start position is negative. A start position greater than the string length searches the whole string.
StringUtils.lastIndexOfIgnoreCase(null, *) = -1
StringUtils.lastIndexOfIgnoreCase(*, null) = -1
StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A") = 7
StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B") = 5
StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4
[中]CharSequence中最后一个索引的区分大小写的查找。
空字符序列将返回-1。负起始位置返回-1。除非起始位置为负值,否则空(“”)搜索字符序列始终匹配。大于字符串长度的起始位置搜索整个字符串。
StringUtils.lastIndexOfIgnoreCase(null, *) = -1
StringUtils.lastIndexOfIgnoreCase(*, null) = -1
StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A") = 7
StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B") = 5
StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* <p>Case in-sensitive find of the last index within a CharSequence.</p>
*
* <p>A {@code null} CharSequence will return {@code -1}.
* A negative start position returns {@code -1}.
* An empty ("") search CharSequence always matches unless the start position is negative.
* A start position greater than the string length searches the whole string.</p>
*
* <pre>
* StringUtils.lastIndexOfIgnoreCase(null, *) = -1
* StringUtils.lastIndexOfIgnoreCase(*, null) = -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A") = 7
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B") = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4
* </pre>
*
* @param str the CharSequence to check, may be null
* @param searchStr the CharSequence to find, may be null
* @return the first index of the search CharSequence,
* -1 if no match or {@code null} string input
* @since 2.5
* @since 3.0 Changed signature from lastIndexOfIgnoreCase(String, String) to lastIndexOfIgnoreCase(CharSequence, CharSequence)
*/
public static int lastIndexOfIgnoreCase(final CharSequence str, final CharSequence searchStr) {
if (str == null || searchStr == null) {
return INDEX_NOT_FOUND;
}
return lastIndexOfIgnoreCase(str, searchStr, str.length());
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testLastIndexOfIgnoreCase_String() {
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase(null, null));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("", null));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase(null, ""));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("", "a"));
assertEquals(0, StringUtils.lastIndexOfIgnoreCase("", ""));
assertEquals(8, StringUtils.lastIndexOfIgnoreCase("aabaabaa", ""));
assertEquals(7, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "a"));
assertEquals(7, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A"));
assertEquals(5, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "b"));
assertEquals(5, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B"));
assertEquals(4, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "ab"));
assertEquals(4, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB"));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("ab", "AAB"));
assertEquals(0, StringUtils.lastIndexOfIgnoreCase("aab", "AAB"));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testLastIndexOfIgnoreCase_StringInt() {
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase(null, null, 0));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase(null, null, -1));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase(null, "", 0));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase(null, "", -1));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("", null, 0));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("", null, -1));
assertEquals(0, StringUtils.lastIndexOfIgnoreCase("", "", 0));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("", "", -1));
assertEquals(0, StringUtils.lastIndexOfIgnoreCase("", "", 9));
assertEquals(0, StringUtils.lastIndexOfIgnoreCase("abc", "", 0));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("abc", "", -1));
assertEquals(3, StringUtils.lastIndexOfIgnoreCase("abc", "", 9));
assertEquals(7, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 8));
assertEquals(5, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 8));
assertEquals(4, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB", 8));
assertEquals(2, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 3));
assertEquals(5, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 9));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", -1));
assertEquals(-1, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 0));
assertEquals(0, StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 0));
assertEquals(1, StringUtils.lastIndexOfIgnoreCase("aab", "AB", 1));
}
代码示例来源:origin: virjar/vscrawler
@Override
protected int handleIndex(CharSequence str, CharSequence searchStr, int startPos) {
return StringUtils.lastIndexOfIgnoreCase(str, searchStr, startPos);
}
代码示例来源:origin: de.knightsoft-net/gwt-commons-lang3
/**
* <p>Case in-sensitive find of the last index within a CharSequence.</p>
*
* <p>A {@code null} CharSequence will return {@code -1}.
* A negative start position returns {@code -1}.
* An empty ("") search CharSequence always matches unless the start position is negative.
* A start position greater than the string length searches the whole string.</p>
*
* <pre>
* StringUtils.lastIndexOfIgnoreCase(null, *) = -1
* StringUtils.lastIndexOfIgnoreCase(*, null) = -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A") = 7
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B") = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4
* </pre>
*
* @param str the CharSequence to check, may be null
* @param searchStr the CharSequence to find, may be null
* @return the first index of the search CharSequence,
* -1 if no match or {@code null} string input
* @since 2.5
* @since 3.0 Changed signature from lastIndexOfIgnoreCase(String, String) to lastIndexOfIgnoreCase(CharSequence, CharSequence)
*/
public static int lastIndexOfIgnoreCase(final CharSequence str, final CharSequence searchStr) {
if (str == null || searchStr == null) {
return INDEX_NOT_FOUND;
}
return lastIndexOfIgnoreCase(str, searchStr, str.length());
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
/**
* <p>Case in-sensitive find of the last index within a CharSequence.</p>
*
* <p>A {@code null} CharSequence will return {@code -1}.
* A negative start position returns {@code -1}.
* An empty ("") search CharSequence always matches unless the start position is negative.
* A start position greater than the string length searches the whole string.</p>
*
* <pre>
* StringUtils.lastIndexOfIgnoreCase(null, *) = -1
* StringUtils.lastIndexOfIgnoreCase(*, null) = -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A") = 7
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B") = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4
* </pre>
*
* @param str the CharSequence to check, may be null
* @param searchStr the CharSequence to find, may be null
* @return the first index of the search CharSequence,
* -1 if no match or {@code null} string input
* @since 2.5
* @since 3.0 Changed signature from lastIndexOfIgnoreCase(String, String) to lastIndexOfIgnoreCase(CharSequence, CharSequence)
*/
public static int lastIndexOfIgnoreCase(final CharSequence str, final CharSequence searchStr) {
if (str == null || searchStr == null) {
return INDEX_NOT_FOUND;
}
return lastIndexOfIgnoreCase(str, searchStr, str.length());
}
代码示例来源:origin: io.virtdata/virtdata-lib-curves4
/**
* <p>Case in-sensitive find of the last index within a CharSequence.</p>
*
* <p>A {@code null} CharSequence will return {@code -1}.
* A negative start position returns {@code -1}.
* An empty ("") search CharSequence always matches unless the start position is negative.
* A start position greater than the string length searches the whole string.</p>
*
* <pre>
* StringUtils.lastIndexOfIgnoreCase(null, *) = -1
* StringUtils.lastIndexOfIgnoreCase(*, null) = -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A") = 7
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B") = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4
* </pre>
*
* @param str the CharSequence to check, may be null
* @param searchStr the CharSequence to find, may be null
* @return the first index of the search CharSequence,
* -1 if no match or {@code null} string input
* @since 2.5
* @since 3.0 Changed signature from lastIndexOfIgnoreCase(String, String) to lastIndexOfIgnoreCase(CharSequence, CharSequence)
*/
public static int lastIndexOfIgnoreCase(final CharSequence str, final CharSequence searchStr) {
if (str == null || searchStr == null) {
return INDEX_NOT_FOUND;
}
return lastIndexOfIgnoreCase(str, searchStr, str.length());
}
代码示例来源:origin: org.xworker/xworker_core
public static int lastIndexOfIgnoreCase(ActionContext actionContext){
Thing self = actionContext.getObject("self");
CharSequence cs1 = (CharSequence) self.doAction("getCs1", actionContext);
CharSequence cs2 = (CharSequence) self.doAction("getCs2", actionContext);
Integer startPos = (Integer) self.doAction("getStartPos", actionContext);
return StringUtils.lastIndexOfIgnoreCase(cs1, cs2, startPos);
}
内容来源于网络,如有侵权,请联系作者删除!