主頁 > 後端開發 > String Utils 工具類介紹大全 isAnyEmpty isAnyBlank stripToNull 等,一篇文章找全所有答案!

String Utils 工具類介紹大全 isAnyEmpty isAnyBlank stripToNull 等,一篇文章找全所有答案!

2020-12-31 11:45:58 後端開發

StringUtils工具類介紹

  • 前言
  • 1.isEmpty()
  • 2.isNotEmpty()
  • 3.isAnyEmpty()
  • 4.isNoneEmpty()
  • 5.isBlank()
  • 6.isNotBlank()
  • 7.isAnyBlank()
  • 8.isNoneBlank()
  • 9.trim()
  • 10.trimToNull()
  • 11.trimToEmpty()
  • 12.strip()
  • 13.stripToNull()
  • 14.stripToEmpty()
  • 15.stripStart()
  • 16.stripEnd()
  • 17.stripAll()
  • 18.stripAccents()
  • 19.indexOf()
  • 20.indexOfIgnoreCase()
  • 21.ordinalIndexOf()
  • 22.lastIndexOf()
  • 23.lastOrdinalIndexOf()
  • 24.lastIndexOfIgnoreCase()
  • 25.equals()
  • 26.equalsIgnoreCase()
  • 27.contains()
  • 28.containsIgnoreCase()
  • 29.containsWhitespace()
  • 30.indexOfAny()
  • 31.containsAny()
  • 32.indexOfAnyBut()
  • 33.containsOnly()
  • 34.containsNone()
  • 35.indexOfAny()
  • 36.lastIndexOfAny()
  • 37.substring()
  • 38.left()
  • 39.right()
  • 40.mid()
  • 41.substringBefore()
  • 42.substringAfter()
  • 43.substringBeforeLast()
  • 44.substringAfterLast()
  • 45.substringBetween()
  • 46.substringsBetween()
  • 47.split()
  • 48.splitByWholeSeparator()和splitByWholeSeparatorPreserveAllTokens()
  • 49.splitPreserveAllTokens()
  • 50.splitByCharacterType()
  • 51.splitByCharacterTypeCamelCase()
  • 52.join()
  • 53.deleteWhitespace()
  • 54.removeStart()
  • 55.removeStartIgnoreCase()
  • 56.removeEnd()
  • 57.removeEndIgnoreCase()
  • 58.remove
  • 59.replaceOnce()
  • 60.replacePattern()
  • 61.removePattern()
  • 62.replace()
  • 63.replaceEach()
  • 64.replaceEachRepeatedly()
  • 65.replaceChars()
  • 66.overlay()
  • 67.chomp()
  • 68.chop()
  • 69.repeat()
  • 70.rightPad()
  • 71.leftPad()
  • 72.center()
  • 73.upperCase()
  • 74.lowerCase()
  • 75.capitalize()
  • 76.uncapitalize()
  • 77.swapCase()
  • 78.countMatches()
  • 79.reverse()
  • 80.reverseDelimited()
  • 81.difference()
  • 82.indexOfDifference()
  • 83.toEncodedString()


前言

不多逼逼,直接開始

1.isEmpty()

描述:null與空串是empty的判斷依據,

* StringUtils.isEmpty(null) = true
* StringUtils.isEmpty("") = true
* StringUtils.isEmpty(" ") = false
* StringUtils.isEmpty("bob") = false

2.isNotEmpty()

描述:對isEmpty()取反

* StringUtils.isNotEmpty(null) = false
* StringUtils.isNotEmpty("") = false
* StringUtils.isNotEmpty(" ") = true
* StringUtils.isNotEmpty("bob") = true

3.isAnyEmpty()

描述:isAnyEmpty只要有一個字串為empty,回傳值就為true,

* StringUtils.isAnyEmpty(null) = true
* StringUtils.isAnyEmpty(null, "foo") = true
* StringUtils.isAnyEmpty("", "bar") = true
* StringUtils.isAnyEmpty("bob", "") = true
* StringUtils.isAnyEmpty("  bob  ", null) = true
* StringUtils.isAnyEmpty(" ", "bar") = false
* StringUtils.isAnyEmpty("foo", "bar") = false

4.isNoneEmpty()

描述:null與空串是empty的判斷依據,

* StringUtils.isNoneEmpty(null) = false
* StringUtils.isNoneEmpty(null, "foo") = false
* StringUtils.isNoneEmpty("", "bar") = false
* StringUtils.isNoneEmpty("bob", "") = false
* StringUtils.isNoneEmpty("  bob  ", null) = false
* StringUtils.isNoneEmpty(" ", "bar") = true
* StringUtils.isNoneEmpty("foo", "bar") = true

5.isBlank()

描述:blank的判斷依據是在empty的基礎上添加一個空白符(即空格),也就是說,null、空串、只包含空白符就是blank,isblank回傳true,

* StringUtils.isBlank(null) = true
* StringUtils.isBlank("") = true
* StringUtils.isBlank(" ")  = true
* StringUtils.isBlank("bob") = false
* StringUtils.isBlank("  bob  ") = false

6.isNotBlank()

描述:是對isBlank()取反,

* StringUtils.isNotBlank(null) = false
* StringUtils.isNotBlank("")   = false
* StringUtils.isNotBlank(" ")  = false
* StringUtils.isNotBlank("bob")= true
* StringUtils.isNotBlank("  bob  ") = true

7.isAnyBlank()

描述:只要有一個字符為空白符,就回傳true,

* StringUtils.isAnyBlank(null)   = true
* StringUtils.isAnyBlank(null, "foo") = true
* StringUtils.isAnyBlank(null, null)  = true
* StringUtils.isAnyBlank("", "bar")   = true
* StringUtils.isAnyBlank("bob", "")   = true
* StringUtils.isAnyBlank("  bob  ", null)  = true
* StringUtils.isAnyBlank(" ", "bar")  = true
* StringUtils.isAnyBlank("foo", "bar")= false

8.isNoneBlank()

描述:對isAnyBlank取反,

* StringUtils.isNoneBlank(null)   = false
* StringUtils.isNoneBlank(null, "foo") = false
* StringUtils.isNoneBlank(null, null)  = false
* StringUtils.isNoneBlank("", "bar")   = false
* StringUtils.isNoneBlank("bob", "")   = false
* StringUtils.isNoneBlank("  bob  ", null)  = false
* StringUtils.isNoneBlank(" ", "bar")  = false
* StringUtils.isNoneBlank("foo", "bar")= true

9.trim()

描述:trim功能是修剪字串兩邊的空格,修剪后的空串會保持空串,

* StringUtils.trim(null)= null
* StringUtils.trim("")  = ""
* StringUtils.trim("")  = ""
* StringUtils.trim("abc")    = "abc"
* StringUtils.trim("    abc    ") = "abc"

10.trimToNull()

描述:trimToNull在trim的基礎上,將修剪后的空串轉化為null,

* StringUtils.trimToNull(null)= null
* StringUtils.trimToNull("")  = null
* StringUtils.trimToNull("")  = null
* StringUtils.trimToNull("abc")    = "abc"
* StringUtils.trimToNull("    abc    ") = "abc"

11.trimToEmpty()

描述:trimToEmpty在trim的基礎上,將修剪后的null轉化為空串,

* StringUtils.trimToEmpty(null)= ""
* StringUtils.trimToEmpty("")  = ""
* StringUtils.trimToEmpty("")  = ""
* StringUtils.trimToEmpty("abc")    = "abc"
* StringUtils.trimToEmpty("    abc    ") = "abc"

12.strip()

描述:strip功能與trim對應,有兩個引數的strip多載則可以指定要在字串開頭與結尾需要洗掉的字串,

* StringUtils.strip(null)= null
* StringUtils.strip("")  = ""
* StringUtils.strip("   ")    = ""
* StringUtils.strip("abc")    = "abc"
* StringUtils.strip("  abc")  = "abc"
* StringUtils.strip("abc  ")  = "abc"
* StringUtils.strip(" abc ")  = "abc"
* StringUtils.strip(" ab c ") = "ab c"
* StringUtils.strip(null, *)= null
* StringUtils.strip("", *)  = ""
* StringUtils.strip("abc", null) = "abc"
* StringUtils.strip("  abc", null)    = "abc"
* StringUtils.strip("abc  ", null)    = "abc"
* StringUtils.strip(" abc ", null)    = "abc"
* StringUtils.strip("  abcyx", "xyz") = "  abc"

13.stripToNull()

描述:stripToNull功能與trimToNull對應,有兩個引數的strip多載則可以指定要在字串開頭與結尾需要洗掉的字串,

* StringUtils.stripToNull(null)= null
* StringUtils.stripToNull("")  = null
* StringUtils.stripToNull("   ")    = null
* StringUtils.stripToNull("abc")    = "abc"
* StringUtils.stripToNull("  abc")  = "abc"
* StringUtils.stripToNull("abc  ")  = "abc"
* StringUtils.stripToNull(" abc ")  = "abc"
* StringUtils.stripToNull(" ab c ") = "ab c"

14.stripToEmpty()

描述:stripToEmpty功能與trimToEmpty對應,有兩個引數的strip多載則可以指定要在字串開頭與結尾需要洗掉的字串,

* StringUtils.stripToEmpty(null)= ""
* StringUtils.stripToEmpty("")  = ""
* StringUtils.stripToEmpty("   ")    = ""
* StringUtils.stripToEmpty("abc")    = "abc"
* StringUtils.stripToEmpty("  abc")  = "abc"
* StringUtils.stripToEmpty("abc  ")  = "abc"
* StringUtils.stripToEmpty(" abc ")  = "abc"
* StringUtils.stripToEmpty(" ab c ") = "ab c"

15.stripStart()

描述:stripStart是實作在字串開頭洗掉指定的字串,也就是strip系列方法的主要實作依賴之一,

* StringUtils.stripStart(null, *)= null
* StringUtils.stripStart("", *)  = ""
* StringUtils.stripStart("abc", "")   = "abc"
* StringUtils.stripStart("abc", null) = "abc"
* StringUtils.stripStart("  abc", null)    = "abc"
* StringUtils.stripStart("abc  ", null)    = "abc  "
* StringUtils.stripStart(" abc ", null)    = "abc "
* StringUtils.stripStart("yxabc  ", "xyz") = "abc  "

16.stripEnd()

描述:stripEnd是實作在字串結尾洗掉指定的字串,也就是strip系列方法的主要實作依賴之一,

* StringUtils.stripEnd(null, *)= null
* StringUtils.stripEnd("", *)  = ""
* StringUtils.stripEnd("abc", "")   = "abc"
* StringUtils.stripEnd("abc", null) = "abc"
* StringUtils.stripEnd("  abc", null)    = "  abc"
* StringUtils.stripEnd("abc  ", null)    = "abc"
* StringUtils.stripEnd(" abc ", null)    = " abc"
* StringUtils.stripEnd("  abcyx", "xyz") = "  abc"
* StringUtils.stripEnd("120.00", ".0")   = "12"

17.stripAll()

描述:stripAll有默認洗掉字串陣列的前后空格功能與洗掉指定的前后字串的多載方法,

* StringUtils.stripAll(null)   = null
* StringUtils.stripAll([])= []
* StringUtils.stripAll(["abc", "  abc"]) = ["abc", "abc"]
* StringUtils.stripAll(["abc  ", null])  = ["abc", null]
* StringUtils.stripAll(null, *) = null
* StringUtils.stripAll([], *)   = []
* StringUtils.stripAll(["abc", "  abc"], null) = ["abc", "abc"]
* StringUtils.stripAll(["abc  ", null], null)  = ["abc", null]
* StringUtils.stripAll(["abc  ", null], "yz")  = ["abc  ", null]
* StringUtils.stripAll(["yabcz", null], "yz")  = ["abc", null]

18.stripAccents()

描述:stripAccents是洗掉關于發音的字符,我們基本不會用到,

* StringUtils.stripAccents(null) = null
* StringUtils.stripAccents("")   = ""
* StringUtils.stripAccents("control") = "control"
* StringUtils.stripAccents("éclair")= "eclair"

19.indexOf()

描述:indexOf有四個多載,功能分別為:查找字符序列第一個匹配的字符的位置;根據指定的開始位置,查找字符序列第一個匹配的字符的位置;查找字符序列第一個匹配的字符序列的位置;根據指定的開始位置,查找字符序列第一個匹配的字符序列的位置;

* StringUtils.indexOf(null, *)    = -1
* StringUtils.indexOf("", *) = -1
* StringUtils.indexOf("aabaabaa", 'a') = 0
* StringUtils.indexOf("aabaabaa", 'b') = 2

* StringUtils.indexOf(null, *, *)= -1
* StringUtils.indexOf("", *, *)  = -1
* StringUtils.indexOf("aabaabaa", 'b', 0)  = 2
* StringUtils.indexOf("aabaabaa", 'b', 3)  = 5
* StringUtils.indexOf("aabaabaa", 'b', 9)  = -1
* StringUtils.indexOf("aabaabaa", 'b', -1) = 2

* StringUtils.indexOf(null, *)= -1
* StringUtils.indexOf(*, null)= -1
* StringUtils.indexOf("", "") = 0
* StringUtils.indexOf("", *)  = -1 (except when * = "")
* StringUtils.indexOf("aabaabaa", "a")  = 0
* StringUtils.indexOf("aabaabaa", "b")  = 2
* StringUtils.indexOf("aabaabaa", "ab") = 1
* StringUtils.indexOf("aabaabaa", "")   = 0

* StringUtils.indexOf(null, *, *)= -1
* StringUtils.indexOf(*, null, *)= -1
* StringUtils.indexOf("", "", 0) = 0
* StringUtils.indexOf("", *, 0)  = -1 (except when * = "")
* StringUtils.indexOf("aabaabaa", "a", 0)  = 0
* StringUtils.indexOf("aabaabaa", "b", 0)  = 2
* StringUtils.indexOf("aabaabaa", "ab", 0) = 1
* StringUtils.indexOf("aabaabaa", "b", 3)  = 5
* StringUtils.indexOf("aabaabaa", "b", 9)  = -1
* StringUtils.indexOf("aabaabaa", "b", -1) = 2
* StringUtils.indexOf("aabaabaa", "", 2)   = 2
* StringUtils.indexOf("abc", "", 9)   = 3

20.indexOfIgnoreCase()

描述:indexOfIgnoreCase有二個多載,是indexOf兩個方法忽略大小寫的實作,功能分別為:不區分大小寫地查找字符序列第一個匹配的字符序列的位置;根據指定的開始位置,不分大小寫地查找字符序列第一個匹配的字符序列的位置;

* StringUtils.indexOfIgnoreCase(null, *)= -1
* StringUtils.indexOfIgnoreCase(*, null)= -1
* StringUtils.indexOfIgnoreCase("", "") = 0
* StringUtils.indexOfIgnoreCase("aabaabaa", "a")  = 0
* StringUtils.indexOfIgnoreCase("aabaabaa", "b")  = 2
* StringUtils.indexOfIgnoreCase("aabaabaa", "ab") = 1

* StringUtils.indexOfIgnoreCase(null, *, *)= -1
* StringUtils.indexOfIgnoreCase(*, null, *)= -1
* StringUtils.indexOfIgnoreCase("", "", 0) = 0
* StringUtils.indexOfIgnoreCase("aabaabaa", "A", 0)  = 0
* StringUtils.indexOfIgnoreCase("aabaabaa", "B", 0)  = 2
* StringUtils.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
* StringUtils.indexOfIgnoreCase("aabaabaa", "B", 3)  = 5
* StringUtils.indexOfIgnoreCase("aabaabaa", "B", 9)  = -1
* StringUtils.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
* StringUtils.indexOfIgnoreCase("aabaabaa", "", 2)   = 2
* StringUtils.indexOfIgnoreCase("abc", "", 9)   = 3

21.ordinalIndexOf()

描述:在indexOf的基礎上添加了一個序數引數,功能分別為:根據指定的開序數,查找字符序列第序數個匹配的字符的位置,

* StringUtils.ordinalIndexOf(null, *, *)= -1
* StringUtils.ordinalIndexOf(*, null, *)= -1
* StringUtils.ordinalIndexOf("", "", *) = 0
* StringUtils.ordinalIndexOf("aabaabaa", "a", 1)  = 0
* StringUtils.ordinalIndexOf("aabaabaa", "a", 2)  = 1
* StringUtils.ordinalIndexOf("aabaabaa", "b", 1)  = 2
* StringUtils.ordinalIndexOf("aabaabaa", "b", 2)  = 5
* StringUtils.ordinalIndexOf("aabaabaa", "ab", 1) = 1
* StringUtils.ordinalIndexOf("aabaabaa", "ab", 2) = 4
* StringUtils.ordinalIndexOf("aabaabaa", "", 1)   = 0
* StringUtils.ordinalIndexOf("aabaabaa", "", 2)   = 0

22.lastIndexOf()

描述:lastIndexOf有四個多載,功能分別為:查找字符序列最后一個匹配的字符的位置;根據指定的結束位置,查找字符序列最后一個匹配的字符的位置;查找字符序列最后一個匹配的字符序列的位置;根據指定的結束位置,查找字符序列最后一個匹配的字符序列的位置;

* StringUtils.lastIndexOf(null, *)    = -1
* StringUtils.lastIndexOf("", *) = -1
* StringUtils.lastIndexOf("aabaabaa", 'a') = 7
* StringUtils.lastIndexOf("aabaabaa", 'b') = 5

* StringUtils.lastIndexOf(null, *, *)= -1
* StringUtils.lastIndexOf("", *,  *) = -1
* StringUtils.lastIndexOf("aabaabaa", 'b', 8)  = 5
* StringUtils.lastIndexOf("aabaabaa", 'b', 4)  = 2
* StringUtils.lastIndexOf("aabaabaa", 'b', 0)  = -1
* StringUtils.lastIndexOf("aabaabaa", 'b', 9)  = 5
* StringUtils.lastIndexOf("aabaabaa", 'b', -1) = -1
* StringUtils.lastIndexOf("aabaabaa", 'a', 0)  = 0

* StringUtils.lastIndexOf(null, *)= -1
* StringUtils.lastIndexOf(*, null)= -1
* StringUtils.lastIndexOf("", "") = 0
* StringUtils.lastIndexOf("aabaabaa", "a")  = 7
* StringUtils.lastIndexOf("aabaabaa", "b")  = 5
* StringUtils.lastIndexOf("aabaabaa", "ab") = 4
* StringUtils.lastIndexOf("aabaabaa", "")   = 8

* StringUtils.lastIndexOf(null, *, *)= -1
* StringUtils.lastIndexOf(*, null, *)= -1
* StringUtils.lastIndexOf("aabaabaa", "a", 8)  = 7
* StringUtils.lastIndexOf("aabaabaa", "b", 8)  = 5
* StringUtils.lastIndexOf("aabaabaa", "ab", 8) = 4
* StringUtils.lastIndexOf("aabaabaa", "b", 9)  = 5
* StringUtils.lastIndexOf("aabaabaa", "b", -1) = -1
* StringUtils.lastIndexOf("aabaabaa", "a", 0)  = 0
* StringUtils.lastIndexOf("aabaabaa", "b", 0)  = -1
* StringUtils.lastIndexOf("aabaabaa", "b", 1)  = -1
* StringUtils.lastIndexOf("aabaabaa", "b", 2)  = 2
* StringUtils.lastIndexOf("aabaabaa", "ba", 2)  = -1
* StringUtils.lastIndexOf("aabaabaa", "ba", 2)  = 2

23.lastOrdinalIndexOf()

描述:lastOrdinalIndexOf可以參考OrdinalIndexOf,查找的是倒數ordinal個匹配的字符序列,

 * StringUtils.lastOrdinalIndexOf(null, *, *)= -1
* StringUtils.lastOrdinalIndexOf(*, null, *)= -1
* StringUtils.lastOrdinalIndexOf("", "", *) = 0
* StringUtils.lastOrdinalIndexOf("aabaabaa", "a", 1)  = 7
* StringUtils.lastOrdinalIndexOf("aabaabaa", "a", 2)  = 6
* StringUtils.lastOrdinalIndexOf("aabaabaa", "b", 1)  = 5
* StringUtils.lastOrdinalIndexOf("aabaabaa", "b", 2)  = 2
* StringUtils.lastOrdinalIndexOf("aabaabaa", "ab", 1) = 4
* StringUtils.lastOrdinalIndexOf("aabaabaa", "ab", 2) = 1
* StringUtils.lastOrdinalIndexOf("aabaabaa", "", 1)   = 8
* StringUtils.lastOrdinalIndexOf("aabaabaa", "", 2)   = 8

24.lastIndexOfIgnoreCase()

描述:lastIndexOfIgnoreCase有兩個多載方法,可以參考indexOfIgnoreCase,功能分別為,在忽略大小寫的情況下,查找最后一個匹配的字符序列的位置;根據所給的結束位置,在忽略大小寫的情況下,查找最后一個匹配的字符序列的位置

* StringUtils.lastIndexOfIgnoreCase(null, *)= -1
* StringUtils.lastIndexOfIgnoreCase(*, null)= -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A")  = 7
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B")  = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB") = 4

* StringUtils.lastIndexOfIgnoreCase(null, *, *)= -1
* StringUtils.lastIndexOfIgnoreCase(*, null, *)= -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 8)  = 7
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 8)  = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB", 8) = 4
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 9)  = 5
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", -1) = -1
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 0)  = 0
* StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 0)  = -1

25.equals()

描述:equals是判斷兩個字符序列是否相等,

* StringUtils.equals(null, null)   = true
* StringUtils.equals(null, "abc")  = false
* StringUtils.equals("abc", null)  = false
* StringUtils.equals("abc", "abc") = true
* StringUtils.equals("abc", "ABC") = false

26.equalsIgnoreCase()

描述:equalsIgnoreCase是不區分大小寫地判斷兩個字符序列是否相等,

* StringUtils.equalsIgnoreCase(null, null)   = true
* StringUtils.equalsIgnoreCase(null, "abc")  = false
* StringUtils.equalsIgnoreCase("abc", null)  = false
* StringUtils.equalsIgnoreCase("abc", "abc") = true
* StringUtils.equalsIgnoreCase("abc", "ABC") = true

27.contains()

描述:字符序列seq是否包含字符searchChar,包含回傳true,不包含回傳false

* StringUtils.contains(null, *)= false
* StringUtils.contains(*, null)= false
* StringUtils.contains("", "") = true
* StringUtils.contains("abc", "")   = true
* StringUtils.contains("abc", "a")  = true
* StringUtils.contains("abc", "z")  = false
* StringUtils.contains("", *) = false

28.containsIgnoreCase()

描述:在忽略大小寫的前提下,字符序列str是否包含字符序列searchStr,包含回傳true,不包含回傳false,

* StringUtils.contains(null, *) = false
* StringUtils.contains(*, null) = false
* StringUtils.contains("", "") = true
* StringUtils.contains("abc", "") = true
* StringUtils.contains("abc", "a") = true
* StringUtils.contains("abc", "z") = false
* StringUtils.contains("abc", "A") = true
* StringUtils.contains("abc", "Z") = false

29.containsWhitespace()

描述:判斷字符序列是否包含空格,包含回傳true,否則回傳false

* StringUtils.containsWhitespace("abc") = false;
* StringUtils.containsWhitespace("ab c") = true;

30.indexOfAny()

描述:根據給定的字符陣列或字串,在字符序列中回傳第一個匹配的字符陣列或字串的任意字符的位置,

* StringUtils.indexOfAny(null, *) = -1
* StringUtils.indexOfAny("", *)   = -1
* StringUtils.indexOfAny(*, null) = -1
* StringUtils.indexOfAny(*, [])   = -1
* StringUtils.indexOfAny("zzabyycdxx",['z','a']) = 0
* StringUtils.indexOfAny("zzabyycdxx",['b','y']) = 3
* StringUtils.indexOfAny("aba", ['z']) = -1
* 
* StringUtils.indexOfAny(*, "")    = -1
* StringUtils.indexOfAny("zzabyycdxx", "za") = 0
* StringUtils.indexOfAny("zzabyycdxx", "by") = 3
* StringUtils.indexOfAny("aba","z")= -1

31.containsAny()

描述:根據給定的字符陣列或字串,在字符序列中判斷是否包含任意一個字符陣列或字串的字符,包含回傳true,否則回傳false,

* StringUtils.containsAny(null, *) = false
* StringUtils.containsAny("", *)   = false
* StringUtils.containsAny(*, null) = false
* StringUtils.containsAny(*, [])   = false
* StringUtils.containsAny("zzabyycdxx",['z','a']) = true
* StringUtils.containsAny("zzabyycdxx",['b','y']) = true
* StringUtils.containsAny("aba", ['z']) = false

* StringUtils.containsAny(null, *)  = false
* StringUtils.containsAny("", *)    = false
* StringUtils.containsAny(*, null)  = false
* StringUtils.containsAny(*, "")    = false
* StringUtils.containsAny("zzabyycdxx", "za") = true
* StringUtils.containsAny("zzabyycdxx", "by") = true
* StringUtils.containsAny("aba","z")= false

32.indexOfAnyBut()

描述:在字符序列cs中,查找第一個匹配的不在所給字符陣列/字符序列searchChars中的字符的位置,

* StringUtils.indexOfAnyBut(null, *)= -1
* StringUtils.indexOfAnyBut("", *)  = -1
* StringUtils.indexOfAnyBut(*, null)= -1
* StringUtils.indexOfAnyBut(*, [])  = -1
* StringUtils.indexOfAnyBut("zzabyycdxx", new char[] {'z', 'a'} ) = 3
* StringUtils.indexOfAnyBut("aba", new char[] {'z'} )   = 0
* StringUtils.indexOfAnyBut("aba", new char[] {'a', 'b'} )   = -1

* StringUtils.indexOfAnyBut(null, *)  = -1
* StringUtils.indexOfAnyBut("", *)    = -1
* StringUtils.indexOfAnyBut(*, null)  = -1
* StringUtils.indexOfAnyBut(*, "")    = -1
* StringUtils.indexOfAnyBut("zzabyycdxx", "za") = 3
* StringUtils.indexOfAnyBut("zzabyycdxx", "")   = -1
* StringUtils.indexOfAnyBut("aba","ab")    = -1

33.containsOnly()

描述:判斷字符序列cs是否只包含字符陣列或字串valid給定的字符,只包含則回傳true,還有其他字符則回傳false,

* StringUtils.containsOnly(null, *)  = false
* StringUtils.containsOnly(*, null)  = false
* StringUtils.containsOnly("", *)    = true
* StringUtils.containsOnly("ab", '') = false
* StringUtils.containsOnly("abab", 'abc') = true
* StringUtils.containsOnly("ab1", 'abc')  = false
* StringUtils.containsOnly("abz", 'abc')  = false

* StringUtils.containsOnly(null, *)  = false
* StringUtils.containsOnly(*, null)  = false
* StringUtils.containsOnly("", *)    = true
* StringUtils.containsOnly("ab", "") = false
* StringUtils.containsOnly("abab", "abc") = true
* StringUtils.containsOnly("ab1", "abc")  = false
* StringUtils.containsOnly("abz", "abc")  = false

34.containsNone()

描述:檢查字符序列cs是否不包含字符陣列或字串searchChars的字符,不包含回傳true,包含回傳false,

* StringUtils.containsNone(null, *)  = true
* StringUtils.containsNone(*, null)  = true
* StringUtils.containsNone("", *)    = true
* StringUtils.containsNone("ab", '') = true
* StringUtils.containsNone("abab", 'xyz') = true
* StringUtils.containsNone("ab1", 'xyz')  = true
* StringUtils.containsNone("abz", 'xyz')  = false

* StringUtils.containsNone(null, *)  = true
* StringUtils.containsNone(*, null)  = true
* StringUtils.containsNone("", *)    = true
* StringUtils.containsNone("ab", "") = true
* StringUtils.containsNone("abab", "xyz") = true
* StringUtils.containsNone("ab1", "xyz")  = true
* StringUtils.containsNone("abz", "xyz")  = false

35.indexOfAny()

描述:根據給定的字符序列陣列searchStrs,在字符序列str中查找第一個匹配的任意一個字符序列陣列的字符序列的位置,

* StringUtils.indexOfAny(null, *) = -1
* StringUtils.indexOfAny(*, null) = -1
* StringUtils.indexOfAny(*, [])   = -1
* StringUtils.indexOfAny("zzabyycdxx", ["ab","cd"])   = 2
* StringUtils.indexOfAny("zzabyycdxx", ["cd","ab"])   = 2
* StringUtils.indexOfAny("zzabyycdxx", ["mn","op"])   = -1
* StringUtils.indexOfAny("zzabyycdxx", ["zab","aby"]) = 1
* StringUtils.indexOfAny("zzabyycdxx", [""])= 0
* StringUtils.indexOfAny("", [""])= 0
* StringUtils.indexOfAny("", ["a"])    = -1

36.lastIndexOfAny()

描述:根據給定的字符序列陣列searchStrs,在字符序列str中查找最后一個匹配的任意一個字符序列陣列的字符序列的位置,

* StringUtils.lastIndexOfAny(null, *)    = -1
* StringUtils.lastIndexOfAny(*, null)    = -1
* StringUtils.lastIndexOfAny(*, []) = -1
* StringUtils.lastIndexOfAny(*, [null])  = -1
* StringUtils.lastIndexOfAny("zzabyycdxx", ["ab","cd"]) = 6
* StringUtils.lastIndexOfAny("zzabyycdxx", ["cd","ab"]) = 6
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn","op"]) = -1
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn","op"]) = -1
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn",""])   = 10

37.substring()

描述:根據所給的start和end截取字串str,半開半閉、有前無后,

* StringUtils.substring(null, *)   = null
* StringUtils.substring("", *)= ""
* StringUtils.substring("abc", 0)  = "abc"
* StringUtils.substring("abc", 2)  = "c"
* StringUtils.substring("abc", 4)  = ""
* StringUtils.substring("abc", -2) = "bc"
* StringUtils.substring("abc", -4) = "abc"

* StringUtils.substring(null, *, *)    = null
* StringUtils.substring("", * ,  *)    = "";
* StringUtils.substring("abc", 0, 2)   = "ab"
* StringUtils.substring("abc", 2, 0)   = ""
* StringUtils.substring("abc", 2, 4)   = "c"
* StringUtils.substring("abc", 4, 6)   = ""
* StringUtils.substring("abc", 2, 2)   = ""
* StringUtils.substring("abc", -2, -1) = "b"
* StringUtils.substring("abc", -4, 2)  = "ab"

38.left()

描述:跟據所給的pos與len分別獲取字串左邊str的字符,長度都為len,

* StringUtils.left(null, *)    = null
* StringUtils.left(*, -ve)= ""
* StringUtils.left("", *) = ""
* StringUtils.left("abc", 0)   = ""
* StringUtils.left("abc", 2)   = "ab"
* StringUtils.left("abc", 4)   = "abc"

39.right()

描述:跟據所給的pos與len分別獲取字串str右邊的字符,長度都為len,

* StringUtils.right(null, *)    = null
* StringUtils.right(*, -ve)= ""
* StringUtils.right("", *) = ""
* StringUtils.right("abc", 0)   = ""
* StringUtils.right("abc", 2)   = "bc"
* StringUtils.right("abc", 4)   = "abc"

40.mid()

描述:跟據所給的pos與len分別獲取字串str中間的字符,長度都為len

 * StringUtils.mid(null, *, *)    = null
* StringUtils.mid(*, *, -ve)= ""
* StringUtils.mid("", 0, *) = ""
* StringUtils.mid("abc", 0, 2)   = "ab"
* StringUtils.mid("abc", 0, 4)   = "abc"
* StringUtils.mid("abc", 2, 4)   = "c"
* StringUtils.mid("abc", 4, 2)   = ""
* StringUtils.mid("abc", -2, 2)  = "ab"

41.substringBefore()

描述: substringBefore會回傳匹配的第一個分隔符separator之前不包含分隔符的字串,

* StringUtils.substringBefore(null, *) = null
* StringUtils.substringBefore("", *)   = ""
* StringUtils.substringBefore("abc", "a")   = ""
* StringUtils.substringBefore("abcba", "b") = "a"
* StringUtils.substringBefore("abc", "c")   = "ab"
* StringUtils.substringBefore("abc", "d")   = "abc"
* StringUtils.substringBefore("abc", "")    = ""
* StringUtils.substringBefore("abc", null)  = "abc"

42.substringAfter()

描述: substringAfter會回傳匹配的第一個分隔符separator之后不包含分隔符的字串,

* StringUtils.substringAfter(null, *) = null
* StringUtils.substringAfter("", *)   = ""
* StringUtils.substringAfter(*, null) = ""
* StringUtils.substringAfter("abc", "a")   = "bc"
* StringUtils.substringAfter("abcba", "b") = "cba"
* StringUtils.substringAfter("abc", "c")   = ""
* StringUtils.substringAfter("abc", "d")   = ""
* StringUtils.substringAfter("abc", "")    = "abc"

43.substringBeforeLast()

描述:substringBeforeLast會回傳匹配的最后一個分隔符separator之前不包含分隔符的字串,

* StringUtils.substringBeforeLast(null, *) = null
* StringUtils.substringBeforeLast("", *)   = ""
* StringUtils.substringBeforeLast("abcba", "b") = "abc"
* StringUtils.substringBeforeLast("abc", "c")   = "ab"
* StringUtils.substringBeforeLast("a", "a")= ""
* StringUtils.substringBeforeLast("a", "z")= "a"
* StringUtils.substringBeforeLast("a", null)    = "a"
* StringUtils.substringBeforeLast("a", "") = "a"

44.substringAfterLast()

描述:substringAfterLast會回傳匹配的最后一個分隔符separator之后不包含分隔符的字串,

* StringUtils.substringAfterLast(null, *) = null
* StringUtils.substringAfterLast("", *)   = ""
* StringUtils.substringAfterLast(*, "")   = ""
* StringUtils.substringAfterLast(*, null) = ""
* StringUtils.substringAfterLast("abc", "a")   = "bc"
* StringUtils.substringAfterLast("abcba", "b") = "a"
* StringUtils.substringAfterLast("abc", "c")   = ""
* StringUtils.substringAfterLast("a", "a")= ""
* StringUtils.substringAfterLast("a", "z")= ""

45.substringBetween()

描述:substringBetween的兩個多載功能分別為:根據傳入的tag來截取兩個tag間的子字串,僅回傳首次匹配到的子字串,根據傳入的字串open與字串close來截取子字串,僅回傳首次匹配到的子字串,

* StringUtils.substringBetween(null, *)  = null
* StringUtils.substringBetween("", "")   = ""
* StringUtils.substringBetween("", "tag")= null
* StringUtils.substringBetween("tagabctag", null)  = null
* StringUtils.substringBetween("tagabctag", "")    = ""
* StringUtils.substringBetween("tagabctag", "tag") = "abc"

* StringUtils.substringBetween("wx[b]yz", "[", "]") = "b"
* StringUtils.substringBetween(null, *, *)= null
* StringUtils.substringBetween(*, null, *)= null
* StringUtils.substringBetween(*, *, null)= null
* StringUtils.substringBetween("", "", "")= ""
* StringUtils.substringBetween("", "", "]")    = null
* StringUtils.substringBetween("", "[", "]")   = null
* StringUtils.substringBetween("yabcz", "", "")= ""
* StringUtils.substringBetween("yabcz", "y", "z")   = "abc"
* StringUtils.substringBetween("yabczyabcz", "y", "z")   = "abc"

46.substringsBetween()

描述:substringsBetween的功能為:根據傳入的字串open與字串close來截取子字串,回傳
所有匹配到的子字串,所以回傳的物件時字串陣列,

* StringUtils.substringsBetween("[a][b][c]", "[", "]") = ["a","b","c"]
* StringUtils.substringsBetween(null, *, *)  = null
* StringUtils.substringsBetween(*, null, *)  = null
* StringUtils.substringsBetween(*, *, null)  = null
* StringUtils.substringsBetween("", "[", "]")= []

47.split()

描述:split的多載功能分別為:將字符空格作為分隔符,回傳字串str分隔后的字串陣列,將傳入的字符separatorChar作為分隔符,回傳字串str分隔后的字串陣列,將傳入的字串separatorChars作為分隔符,回傳字串str分隔后的字串陣列,將傳入的字串separatorChars作為分隔符,回傳字串str分隔后長度不大于max的字串陣列,多余的部分不分割,并入最后一個元素,

* StringUtils.split(null)  = null
* StringUtils.split("")    = []
* StringUtils.split("abc def")  = ["abc", "def"]
* StringUtils.split("abc  def") = ["abc", "def"]
* StringUtils.split(" abc ")    = ["abc"]

* StringUtils.split(null, *)    = null
* StringUtils.split("", *) = []
* StringUtils.split("a.b.c", '.')    = ["a", "b", "c"]
* StringUtils.split("a..b.c", '.')   = ["a", "b", "c"]
* StringUtils.split("a:b:c", '.')    = ["a:b:c"]
* StringUtils.split("a b c", ' ')    = ["a", "b", "c"]

* StringUtils.split(null, *)    = null
* StringUtils.split("", *) = []
* StringUtils.split("abc def", null) = ["abc", "def"]
* StringUtils.split("abc def", " ")  = ["abc", "def"]
* StringUtils.split("abc  def", " ") = ["abc", "def"]
* StringUtils.split("ab:cd:ef", ":") = ["ab", "cd", "ef"]

* StringUtils.split(null, *, *)  = null
* StringUtils.split("", *, *)    = []
* StringUtils.split("ab cd ef", null, 0)   = ["ab", "cd", "ef"]
* StringUtils.split("ab   cd ef", null, 0) = ["ab", "cd", "ef"]
* StringUtils.split("ab:cd:ef", ":", 0)    = ["ab", "cd", "ef"]
* StringUtils.split("ab:cd:ef", ":", 2)    = ["ab", "cd:ef"]

48.splitByWholeSeparator()和splitByWholeSeparatorPreserveAllTokens()

描述:splitByWholeSeparator的多載功能分別為:將傳入的字串separator作為分隔符,回傳字串str分隔后的字串陣列,

* StringUtils.splitByWholeSeparator(null, *)= null
* StringUtils.splitByWholeSeparator("", *)  = []
* StringUtils.splitByWholeSeparator("ab de fg", null) = ["ab", "de", "fg"]
* StringUtils.splitByWholeSeparator("ab   de fg", null)    = ["ab", "de", "fg"]
* StringUtils.splitByWholeSeparator("ab:cd:ef", ":")  = ["ab", "cd", "ef"]
* StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-") = ["ab", "cd", "ef"]

* StringUtils.splitByWholeSeparator(null, *, *)= null
* StringUtils.splitByWholeSeparator("", *, *)  = []
* StringUtils.splitByWholeSeparator("ab de fg", null, 0) = ["ab", "de", "fg"]
* StringUtils.splitByWholeSeparator("ab   de fg", null, 0)    = ["ab", "de", "fg"]
* StringUtils.splitByWholeSeparator("ab:cd:ef", ":", 2)  = ["ab", "cd:ef"]
* StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", 5) = ["ab", "cd", "ef"]
* StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", 2) = ["ab", "cd-!-ef"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens(null, *)= null
* StringUtils.splitByWholeSeparatorPreserveAllTokens("", *)  = []
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null) = ["ab", "de", "fg"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab   de fg", null)    = ["ab", "", "", "de", "fg"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab:cd:ef", ":")  = ["ab", "cd", "ef"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-") = ["ab", "cd", "ef"]

* StringUtils.splitByWholeSeparatorPreserveAllTokens(null, *, *)= null
* StringUtils.splitByWholeSeparatorPreserveAllTokens("", *, *)  = []
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null, 0) = ["ab", "de", "fg"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab   de fg", null, 0)    = ["ab", "", "", "de", "fg"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab:cd:ef", ":", 2)  = ["ab", "cd:ef"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-", 5) = ["ab", "cd", "ef"]
* StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-", 2) = ["ab", "cd-!-ef"]

49.splitPreserveAllTokens()

描述:splitPreserveAllTokens的四個多載功能分別為:
根據空格作為分隔符,將字串str分隔為字串陣列,重復的分隔符是空串的分隔,
將傳入的separatorChar作為分隔符,將字串str分隔為字串陣列,重復的分隔符是空串的分隔,
將傳入的separatorChars作為分隔符,將字串str分隔為字串陣列,重復的分隔符是空串的分隔,
將傳入的separatorChars作為分隔符,將字串str分隔為字串陣列,陣列大小不大于max,余下的并入最后一個陣列元素,重復的分隔符是空串的分隔,

* StringUtils.splitPreserveAllTokens(null)  = null
* StringUtils.splitPreserveAllTokens("")    = []
* StringUtils.splitPreserveAllTokens("abc def")  = ["abc", "def"]
* StringUtils.splitPreserveAllTokens("abc  def") = ["abc", "", "def"]
* StringUtils.splitPreserveAllTokens(" abc ")    = ["", "abc", ""]

* StringUtils.splitPreserveAllTokens(null, *)    = null
* StringUtils.splitPreserveAllTokens("", *) = []
* StringUtils.splitPreserveAllTokens("a.b.c", '.')    = ["a", "b", "c"]
* StringUtils.splitPreserveAllTokens("a..b.c", '.')   = ["a", "", "b", "c"]
* StringUtils.splitPreserveAllTokens("a:b:c", '.')    = ["a:b:c"]
* StringUtils.splitPreserveAllTokens("a\tb\nc", null) = ["a", "b", "c"]
* StringUtils.splitPreserveAllTokens("a b c", ' ')    = ["a", "b", "c"]
* StringUtils.splitPreserveAllTokens("a b c ", ' ')   = ["a", "b", "c", ""]
* StringUtils.splitPreserveAllTokens("a b c  ", ' ')   = ["a", "b", "c", "", ""]
* StringUtils.splitPreserveAllTokens(" a b c", ' ')   = ["", a", "b", "c"]
* StringUtils.splitPreserveAllTokens("  a b c", ' ')  = ["", "", a", "b", "c"]
* StringUtils.splitPreserveAllTokens(" a b c ", ' ')  = ["", a", "b", "c", ""]

* StringUtils.splitPreserveAllTokens(null, *) = null
* StringUtils.splitPreserveAllTokens("", *)   = []
* StringUtils.splitPreserveAllTokens("abc def", null)   = ["abc", "def"]
* StringUtils.splitPreserveAllTokens("abc def", " ")    = ["abc", "def"]
* StringUtils.splitPreserveAllTokens("abc  def", " ")   = ["abc", "", def"]
* StringUtils.splitPreserveAllTokens("ab:cd:ef", ":")   = ["ab", "cd", "ef"]
* StringUtils.splitPreserveAllTokens("ab:cd:ef:", ":")  = ["ab", "cd", "ef", ""]
* StringUtils.splitPreserveAllTokens("ab:cd:ef::", ":") = ["ab", "cd", "ef", "", ""]
* StringUtils.splitPreserveAllTokens("ab::cd:ef", ":")  = ["ab", "", cd", "ef"]
* StringUtils.splitPreserveAllTokens(":cd:ef", ":")= ["", cd", "ef"]
* StringUtils.splitPreserveAllTokens("::cd:ef", ":")    = ["", "", cd", "ef"]
* StringUtils.splitPreserveAllTokens(":cd:ef:", ":")    = ["", cd", "ef", ""]

* StringUtils.splitPreserveAllTokens(null, *, *)  = null
* StringUtils.splitPreserveAllTokens("", *, *)    = []
* StringUtils.splitPreserveAllTokens("ab de fg", null, 0)   = ["ab", "cd", "ef"]
* StringUtils.splitPreserveAllTokens("ab   de fg", null, 0) = ["ab", "cd", "ef"]
* StringUtils.splitPreserveAllTokens("ab:cd:ef", ":", 0)    = ["ab", "cd", "ef"]
* StringUtils.splitPreserveAllTokens("ab:cd:ef", ":", 2)    = ["ab", "cd:ef"]
* StringUtils.splitPreserveAllTokens("ab   de fg", null, 2) = ["ab", "  de fg"]
* StringUtils.splitPreserveAllTokens("ab   de fg", null, 3) = ["ab", "", " de fg"]
* StringUtils.splitPreserveAllTokens("ab   de fg", null, 4) = ["ab", "", "", "de fg"]

50.splitByCharacterType()

描述:按照字串型別來劃分字串str,并回傳字串陣列,大小寫、數字、特殊字符,

* StringUtils.splitByCharacterType(null)    = null
* StringUtils.splitByCharacterType("") = []
* StringUtils.splitByCharacterType("ab de fg")   = ["ab", " ", "de", " ", "fg"]
* StringUtils.splitByCharacterType("ab   de fg") = ["ab", "   ", "de", " ", "fg"]
* StringUtils.splitByCharacterType("ab:cd:ef")   = ["ab", ":", "cd", ":", "ef"]
* StringUtils.splitByCharacterType("number5")    = ["number", "5"]
* StringUtils.splitByCharacterType("fooBar")= ["foo", "B", "ar"]
* StringUtils.splitByCharacterType("foo200Bar")  = ["foo", "200", "B", "ar"]
* StringUtils.splitByCharacterType("ASFRules")   = ["ASFR", "ules"]

51.splitByCharacterTypeCamelCase()

描述:在splitByCharacterType的基礎上,加入駝峰命名的規則來分隔字串,(僅對大小寫有影響)

* StringUtils.splitByCharacterTypeCamelCase(null)    = null
* StringUtils.splitByCharacterTypeCamelCase("") = []
* StringUtils.splitByCharacterTypeCamelCase("ab de fg")   = ["ab", " ", "de", " ", "fg"]
* StringUtils.splitByCharacterTypeCamelCase("ab   de fg") = ["ab", "   ", "de", " ", "fg"]
* StringUtils.splitByCharacterTypeCamelCase("ab:cd:ef")   = ["ab", ":", "cd", ":", "ef"]
* StringUtils.splitByCharacterTypeCamelCase("number5")    = ["number", "5"]
* StringUtils.splitByCharacterTypeCamelCase("fooBar")= ["foo", "Bar"]
* StringUtils.splitByCharacterTypeCamelCase("foo200Bar")  = ["foo", "200", "Bar"]
* StringUtils.splitByCharacterTypeCamelCase("ASFRules")   = ["ASF", "Rules"]

52.join()

描述1:將陣列元素合并為一個字串,元素之間沒有分隔符,

* StringUtils.join(null)  = null
* StringUtils.join([])    = ""
* StringUtils.join([null])= ""
* StringUtils.join(["a", "b", "c"]) = "abc"
* StringUtils.join([null, "", "a"]) = "a"

描述2:根據傳入引數型別的不同,將傳入的陣列合并為一個字串,各元素間的分隔符按照傳入的separator設定,

* StringUtils.join(null, *)= null
* StringUtils.join([], *)  = ""
* StringUtils.join([null], *)   = ""
* StringUtils.join(["a", "b", "c"], ';')  = "a;b;c"
* StringUtils.join(["a", "b", "c"], null) = "abc"
* StringUtils.join([null, "", "a"], ';')  = ";;a"

* StringUtils.join(null, *)= null
* StringUtils.join([], *)  = ""
* StringUtils.join([null], *)   = ""
* StringUtils.join([1, 2, 3], ';')  = "1;2;3"
* StringUtils.join([1, 2, 3], null) = "123"

描述3:根據傳入引數型別的不同,將傳入的陣列按照傳入的元素起始位置startIndex和結束位置endIndex合并為一個字串,各元素間的分隔符按照傳入的separator設定,

* StringUtils.join(null, *,2,4)= null
* StringUtils.join([], *,4,5)  = ""
* StringUtils.join([null], *,1,5)   = ""
* StringUtils.join(["a", "b", "c","d", "e"], ';',1,4)  = "b;c;d"
* StringUtils.join(["a", "b", "c","d", "e"], null,1,4) = "bcd"
* StringUtils.join([null, "", "a", "",null], ';',1,4)  = ";a;"

* StringUtils.join(null, *,2,4)= null
* StringUtils.join([], *,2,4)  = ""
* StringUtils.join([null], *,1,3)   = ""
* StringUtils.join([1, 2, 3, 4, 5], ';',1,5)  = "2;3;4;5"
* StringUtils.join([1, 2, 3, 4, 5], null,1,5) = "2345"

描述4:根據傳入的分隔字串separator,將陣列合并為字串,各陣列元素間用separator隔開,

* StringUtils.join(null, *) = null
* StringUtils.join([], *)   = ""
* StringUtils.join([null], *)    = ""
* StringUtils.join(["a", "b", "c"], "--")  = "a--b--c"
* StringUtils.join(["a", "b", "c"], null)  = "abc"
* StringUtils.join(["a", "b", "c"], "")    = "abc"
* StringUtils.join([null, "", "a"], ',')   = ",,a"

描述5:根據傳入的分隔字串separator,將陣列開始位置startIndex與結位置endIndex間的元素,合并為字串,各陣列元素間用separator隔開,

* StringUtils.join(null, *, *, *) = null
* StringUtils.join([], *, *, *)   = ""
* StringUtils.join([null], *, *, *)    = ""
* StringUtils.join(["a", "b", "c"], "--", 0, 3)  = "a--b--c"
* StringUtils.join(["a", "b", "c"], "--", 1, 3)  = "b--c"
* StringUtils.join(["a", "b", "c"], "--", 2, 3)  = "c"
* StringUtils.join(["a", "b", "c"], "--", 2, 2)  = ""
* StringUtils.join(["a", "b", "c"], null, 0, 3)  = "abc"
* StringUtils.join(["a", "b", "c"], "", 0, 3)    = "abc"
* StringUtils.join([null, "", "a"], ',', 0, 3)   = ",,a"

53.deleteWhitespace()

描述:洗掉字串中的所有空白符,回傳新字串,

* StringUtils.deleteWhitespace(null)    = null
* StringUtils.deleteWhitespace("") = ""
* StringUtils.deleteWhitespace("abc")   = "abc"
* StringUtils.deleteWhitespace("   ab  c  ") = "abc"

54.removeStart()

描述:僅當字串remove位于str開頭時才洗掉remove,回傳洗掉后的str,否則回傳原串,

* StringUtils.removeStart(null, *) = null
* StringUtils.removeStart("", *)   = ""
* StringUtils.removeStart(*, null) = *
* StringUtils.removeStart("www.domain.com", "www.")   = "domain.com"
* StringUtils.removeStart("domain.com", "www.")  = "domain.com"
* StringUtils.removeStart("www.domain.com", "domain") = "www.domain.com"
* StringUtils.removeStart("abc", "")    = "abc"

55.removeStartIgnoreCase()

描述:在區分大小寫 的情況下,僅當字串remove位于str開頭時才洗掉remove,回傳洗掉后的str,否則回傳原串,

* StringUtils.removeStartIgnoreCase(null, *) = null
* StringUtils.removeStartIgnoreCase("", *)   = ""
* StringUtils.removeStartIgnoreCase(*, null) = *
* StringUtils.removeStartIgnoreCase("www.domain.com", "www.")   = "domain.com"
* StringUtils.removeStartIgnoreCase("www.domain.com", "WWW.")   = "domain.com"
* StringUtils.removeStartIgnoreCase("domain.com", "www.")  = "domain.com"
* StringUtils.removeStartIgnoreCase("www.domain.com", "domain") = "www.domain.com"
* StringUtils.removeStartIgnoreCase("abc", "")    = "ab

56.removeEnd()

描述:僅當字串remove位于str結尾時才洗掉remove,回傳洗掉后的str,否則回傳原串,

* StringUtils.removeEnd(null, *) = null
* StringUtils.removeEnd("", *)   = ""
* StringUtils.removeEnd(*, null) = *
* StringUtils.removeEnd("www.domain.com", ".com.")  = "www.domain.com"
* StringUtils.removeEnd("www.domain.com", ".com")   = "www.domain"
* StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com"
* StringUtils.removeEnd("abc", "")    = "abc"

57.removeEndIgnoreCase()

描述:在區分大小寫 的情況下,僅當字串remove位于str結尾時才洗掉remove,回傳洗掉后的str,否則回傳原串,

* StringUtils.removeEndIgnoreCase(null, *) = null
* StringUtils.removeEndIgnoreCase("", *)   = ""
* StringUtils.removeEndIgnoreCase(*, null) = *
* StringUtils.removeEndIgnoreCase("www.domain.com", ".com.")  = "www.domain.com"
* StringUtils.removeEndIgnoreCase("www.domain.com", ".com")   = "www.domain"
* StringUtils.removeEndIgnoreCase("www.domain.com", "domain") = "www.domain.com"
* StringUtils.removeEndIgnoreCase("abc", "")    = "abc"
* StringUtils.removeEndIgnoreCase("www.domain.com", ".COM") = "www.domain")
* StringUtils.removeEndIgnoreCase("www.domain.COM", ".com") = "www.domain")

58.remove

描述1:洗掉字串str中所有的remove子串,回傳新串,

* StringUtils.remove(null, *)   = null
* StringUtils.remove("", *)= ""
* StringUtils.remove(*, null)   = *
* StringUtils.remove(*, "")= *
* StringUtils.remove("queued", "ue") = "qd"
* StringUtils.remove("queued", "zz") = "queued"

描述2:洗掉字串str中所有的remove字符,回傳新串,

* StringUtils.remove(null, *)  = null
* StringUtils.remove("", *)    = ""
* StringUtils.remove("queued", 'u') = "qeed"
* StringUtils.remove("queued", 'z') = "queued"

59.replaceOnce()

描述:將字串text中第一個匹配的searchString替換為replacement,

* StringUtils.replaceOnce(null, *, *)   = null
* StringUtils.replaceOnce("", *, *)= ""
* StringUtils.replaceOnce("any", null, *)    = "any"
* StringUtils.replaceOnce("any", *, null)    = "any"
* StringUtils.replaceOnce("any", "", *) = "any"
* StringUtils.replaceOnce("aba", "a", null)  = "aba"
* StringUtils.replaceOnce("aba", "a", "")    = "ba"
* StringUtils.replaceOnce("aba", "a", "z")   = "zba"

60.replacePattern()

描述:在字串source中,將每個匹配正則運算式regex的子字串替換為字串replacement,

61.removePattern()

描述:依賴replacePattern實作,將source中每個匹配的regex子串替換為空串,效果相當于洗掉,回傳新串,

62.replace()

描述1:在字串text中,替換所有searchString字串為replacement字串,

* StringUtils.replace(null, *, *)   = null
* StringUtils.replace("", *, *)= ""
* StringUtils.replace("any", null, *)    = "any"
* StringUtils.replace("any", *, null)    = "any"
* StringUtils.replace("any", "", *) = "any"
* StringUtils.replace("aba", "a", null)  = "aba"
* StringUtils.replace("aba", "a", "")    = "b"
* StringUtils.replace("aba", "a", "z")   = "zbz"

描述2:在字串text中,替換searchString字串為replacement字串,最多替換max個,

* StringUtils.replace(null, *, *, *)    = null
* StringUtils.replace("", *, *, *) = ""
* StringUtils.replace("any", null, *, *)= "any"
* StringUtils.replace("any", *, null, *)= "any"
* StringUtils.replace("any", "", *, *)  = "any"
* StringUtils.replace("any", *, *, 0)   = "any"
* StringUtils.replace("abaa", "a", null, -1) = "abaa"
* StringUtils.replace("abaa", "a", "", -1)   = "b"
* StringUtils.replace("abaa", "a", "z", 0)   = "abaa"
* StringUtils.replace("abaa", "a", "z", 1)   = "zbaa"
* StringUtils.replace("abaa", "a", "z", 2)   = "zbza"
* StringUtils.replace("abaa", "a", "z", -1)  = "zbzz"

63.replaceEach()

描述:在字串text中,將所有的searchList字串陣列元素與replacement字串陣列元素一次性一一對應替換,(即所有元素同時替換)

*  StringUtils.replaceEach(null, *, *)   = null
*  StringUtils.replaceEach("", *, *)= ""
*  StringUtils.replaceEach("aba", null, null) = "aba"
*  StringUtils.replaceEach("aba", new String[0], null) = "aba"
*  StringUtils.replaceEach("aba", null, new String[0]) = "aba"
*  StringUtils.replaceEach("aba", new String[]{"a"}, null)  = "aba"
*  StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""})  = "b"
*  StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"})  = "aba"
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"})  = "wcte"
*  (example of how it does not repeat)
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"})  = "dcte"

64.replaceEachRepeatedly()

描述:在字串text中,將所有的searchList字串陣列元素與replacement字串陣列元素串行一一對應替換,(即按每個元素替換后的結果作為下個元素替換的原串)

*  StringUtils.replaceEach(null, *, *, *) = null
*  StringUtils.replaceEach("", *, *, *) = ""
*  StringUtils.replaceEach("aba", null, null, *) = "aba"
*  StringUtils.replaceEach("aba", new String[0], null, *) = "aba"
*  StringUtils.replaceEach("aba", null, new String[0], *) = "aba"
*  StringUtils.replaceEach("aba", new String[]{"a"}, null, *) = "aba"
*  StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}, *) = "b"
*  StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}, *) = "aba"
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}, *) = "wcte"
*  (example of how it repeats)
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, false) = "dcte"
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, true) = "tcte"
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, true) = IllegalStateException
*  StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, false) = "dcabe"

65.replaceChars()

描述1:在str中匹配字符searchChar,并以字符replaceChar替代,

* StringUtils.replaceChars(null, *, *)   = null
* StringUtils.replaceChars("", *, *)= ""
* StringUtils.replaceChars("abcba", 'b', 'y') = "aycya"
* StringUtils.replaceChars("abcba", 'z', 'y') = "abcba"

描述2:一次替換字串中的多個字符,此方法也可用于洗掉字符,拿searchChars的index,去replaceChars找相應的index然后替換掉,

* StringUtils.replaceChars(null, *, *) = null
* StringUtils.replaceChars("", *, *)   = ""
* StringUtils.replaceChars("abc", null, *)  = "abc"
* StringUtils.replaceChars("abc", "", *)    = "abc"
* StringUtils.replaceChars("abc", "b", null)= "ac"
* StringUtils.replaceChars("abc", "b", "")  = "ac"
* StringUtils.replaceChars("abcba", "bc", "yz")  = "ayzya"
* StringUtils.replaceChars("abcba", "bc", "y")   = "ayya"
* StringUtils.replaceChars("abcba", "bc", "yzx") = "ayzya"

66.overlay()

描述:根據start和end將str字串中相應位置的字串(可以是空串),替換為overlay

* StringUtils.overlay(null, *, *, *)  = null
* StringUtils.overlay("", "abc", 0, 0)= "abc"
* StringUtils.overlay("abcdef", null, 2, 4)= "abef"
* StringUtils.overlay("abcdef", "", 2, 4)  = "abef"
* StringUtils.overlay("abcdef", "", 4, 2)  = "abef"
* StringUtils.overlay("abcdef", "zzzz", 2, 4)   = "abzzzzef"
* StringUtils.overlay("abcdef", "zzzz", 4, 2)   = "abzzzzef"
* StringUtils.overlay("abcdef", "zzzz", -1, 4)  = "zzzzef"
* StringUtils.overlay("abcdef", "zzzz", 2, 8)   = "abzzzz"
* StringUtils.overlay("abcdef", "zzzz", -2, -3) = "zzzzabcdef"
* StringUtils.overlay("abcdef", "zzzz", 8, 10)  = "abcdefzzzz"

67.chomp()

描述:將字串str結尾的’\r’ ‘\n’ ‘\r\n’ 中的一種洗掉(優先洗掉’\r\n’),

* StringUtils.chomp(null)= null
* StringUtils.chomp("")  = ""
* StringUtils.chomp("abc \r") = "abc "
* StringUtils.chomp("abc\n")  = "abc"
* StringUtils.chomp("abc\r\n")= "abc"
* StringUtils.chomp("abc\r\n\r\n") = "abc\r\n"
* StringUtils.chomp("abc\n\r")= "abc\n"
* StringUtils.chomp("abc\n\rabc")  = "abc\n\rabc"
* StringUtils.chomp("\r")= ""
* StringUtils.chomp("\n")= ""
* StringUtils.chomp("\r\n")   = ""

68.chop()

描述:洗掉字串str的最后一個字符,’\r\n’算一個字符,

* StringUtils.chop(null)= null
* StringUtils.chop("")  = ""
* StringUtils.chop("abc \r") = "abc "
* StringUtils.chop("abc\n")  = "abc"
* StringUtils.chop("abc\r\n")= "abc"
* StringUtils.chop("abc")    = "ab"
* StringUtils.chop("abc\nabc")    = "abc\nab"
* StringUtils.chop("a") = ""
* StringUtils.chop("\r")= ""
* StringUtils.chop("\n")= ""
* StringUtils.chop("\r\n")   = ""

69.repeat()

描述1:重復字串str,次數為repeat次,

* StringUtils.repeat(null, 2) = null
* StringUtils.repeat("", 0)   = ""
* StringUtils.repeat("", 2)   = ""
* StringUtils.repeat("a", 3)  = "aaa"
* StringUtils.repeat("ab", 2) = "abab"
* StringUtils.repeat("a", -2) = ""

描述2:重復字串str,次數為repeat次,分隔符為separator,

* StringUtils.repeat(null, null, 2) = null
* StringUtils.repeat(null, "x", 2)  = null
* StringUtils.repeat("", null, 0)   = ""
* StringUtils.repeat("", "", 2)= ""
* StringUtils.repeat("", "x", 3)    = "xxx"
* StringUtils.repeat("?", ", ", 3)  = "?, ?, ?"

描述3:重復字符ch,次數為repeat次,

* StringUtils.repeat('e', 0)  = ""
* StringUtils.repeat('e', 3)  = "eee"
* StringUtils.repeat('e', -2) = ""

70.rightPad()

描述1:若str長度不足size,則使用空格在字串后補全,

* StringUtils.rightPad(null, *)   = null
* StringUtils.rightPad("", 3)= "   "
* StringUtils.rightPad("bat", 3)  = "bat"
* StringUtils.rightPad("bat", 5)  = "bat  "
* StringUtils.rightPad("bat", 1)  = "bat"
* StringUtils.rightPad("bat", -1) = "bat"

描述2:若str長度不足size,則使用padChar字符在字串后補全,

* StringUtils.rightPad(null, *, *)= null
* StringUtils.rightPad("", 3, 'z')= "zzz"
* StringUtils.rightPad("bat", 3, 'z')  = "bat"
* StringUtils.rightPad("bat", 5, 'z')  = "batzz"
* StringUtils.rightPad("bat", 1, 'z')  = "bat"
* StringUtils.rightPad("bat", -1, 'z') = "bat"

描述3:若str長度不足size,則使用padStr字串在字串后補全,padStr可以截斷,

* StringUtils.rightPad(null, *, *) = null
* StringUtils.rightPad("", 3, "z") = "zzz"
* StringUtils.rightPad("bat", 3, "yz")  = "bat"
* StringUtils.rightPad("bat", 5, "yz")  = "batyz"
* StringUtils.rightPad("bat", 8, "yz")  = "batyzyzy"
* StringUtils.rightPad("bat", 1, "yz")  = "bat"
* StringUtils.rightPad("bat", -1, "yz") = "bat"
* StringUtils.rightPad("bat", 5, null)  = "bat  "
* StringUtils.rightPad("bat", 5, "")    = "bat  "

71.leftPad()

描述:與right對應,在字串前補全,

* StringUtils.leftPad(null, *)   = null
* StringUtils.leftPad("", 3)= "   "
* StringUtils.leftPad("bat", 3)  = "bat"
* StringUtils.leftPad("bat", 5)  = "  bat"
* StringUtils.leftPad("bat", 1)  = "bat"
* StringUtils.leftPad("bat", -1) = "bat"

* StringUtils.leftPad(null, *, *)= null
* StringUtils.leftPad("", 3, 'z')= "zzz"
* StringUtils.leftPad("bat", 3, 'z')  = "bat"
* StringUtils.leftPad("bat", 5, 'z')  = "zzbat"
* StringUtils.leftPad("bat", 1, 'z')  = "bat"
* StringUtils.leftPad("bat", -1, 'z') = "bat"

* StringUtils.leftPad(null, *, *) = null
* StringUtils.leftPad("", 3, "z") = "zzz"
* StringUtils.leftPad("bat", 3, "yz")  = "bat"
* StringUtils.leftPad("bat", 5, "yz")  = "yzbat"
* StringUtils.leftPad("bat", 8, "yz")  = "yzyzybat"
* StringUtils.leftPad("bat", 1, "yz")  = "bat"
* StringUtils.leftPad("bat", -1, "yz") = "bat"
* StringUtils.leftPad("bat", 5, null)  = "  bat"
* StringUtils.leftPad("bat", 5, "")    = "  bat"

72.center()

描述1:回傳一個字串,長度為size,str位于新串中心,空格補齊,

* StringUtils.center(null, *)   = null
* StringUtils.center("", 4)= "    "
* StringUtils.center("ab", -1)  = "ab"
* StringUtils.center("ab", 4)   = " ab "
* StringUtils.center("abcd", 2) = "abcd"
* StringUtils.center("a", 4)    = " a  "

描述2:回傳一個字串,長度為size,str位于新串中心,padChar補齊,

* StringUtils.center(null, *, *)= null
* StringUtils.center("", 4, ' ')= "    "
* StringUtils.center("ab", -1, ' ')  = "ab"
* StringUtils.center("ab", 4, ' ')   = " ab "
* StringUtils.center("abcd", 2, ' ') = "abcd"
* StringUtils.center("a", 4, ' ')    = " a  "
* StringUtils.center("a", 4, 'y')    = "yayy"

描述3:回傳一個字串,長度為size,str位于新串中心,padStr補齊,padStr可拆分,

* StringUtils.center(null, *, *)= null
* StringUtils.center("", 4, " ")= "    "
* StringUtils.center("ab", -1, " ")  = "ab"
* StringUtils.center("ab", 4, " ")   = " ab "
* StringUtils.center("abcd", 2, " ") = "abcd"
* StringUtils.center("a", 4, " ")    = " a  "
* StringUtils.center("a", 4, "yz")   = "yayz"
* StringUtils.center("abc", 7, null) = "  abc  "
* StringUtils.center("abc", 7, "")   = "  abc  "

73.upperCase()

描述:將字串轉化為大寫,

* StringUtils.upperCase(null)  = null
* StringUtils.upperCase("")    = ""
* StringUtils.upperCase("aBc") = "ABC"

74.lowerCase()

描述:將字串轉化為小寫,

* StringUtils.lowerCase(null)  = null
* StringUtils.lowerCase("")    = ""
* StringUtils.lowerCase("aBc") = "abc"

75.capitalize()

描述:將字串首字符轉化為大寫,

* StringUtils.capitalize(null)  = null
* StringUtils.capitalize("")    = ""
* StringUtils.capitalize("cat") = "Cat"
* StringUtils.capitalize("cAt") = "CAt"

76.uncapitalize()

描述:將字串首字符轉化為小寫,

* StringUtils.uncapitalize(null)  = null
* StringUtils.uncapitalize("")    = ""
* StringUtils.uncapitalize("Cat") = "cat"
* StringUtils.uncapitalize("CAT") = "cAT"

77.swapCase()

描述:字串大寫轉小寫,小寫轉大寫,

* StringUtils.swapCase(null)  = null
* StringUtils.swapCase("")    = ""
* StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"

78.countMatches()

描述:計算字符序列str中字符序列sub的數量,

* StringUtils.countMatches("", *)    = 0
* StringUtils.countMatches("abba", null)  = 0
* StringUtils.countMatches("abba", "")    = 0
* StringUtils.countMatches("abba", "a")   = 2
* StringUtils.countMatches("abba", "ab")  = 1
* StringUtils.countMatches("abba", "xxx") = 0

79.reverse()

描述:反轉字串,

* StringUtils.reverse(null)  = null
* StringUtils.reverse("")    = ""
* StringUtils.reverse("bat") = "tab"

80.reverseDelimited()

描述:反轉由特定字符分隔的字串,

* StringUtils.reverseDelimited(null, *) = null
* StringUtils.reverseDelimited("", *)   = ""
* StringUtils.reverseDelimited("a.b.c", 'x') = "a.b.c"
* StringUtils.reverseDelimited("a.b.c", ".") = "c.b.a"

81.difference()

描述:回傳str2跟str1比較特有的部分,

* StringUtils.difference(null, null) = null
* StringUtils.difference("", "") = ""
* StringUtils.difference("", "abc") = "abc"
* StringUtils.difference("abc", "") = ""
* StringUtils.difference("abc", "abc") = ""
* StringUtils.difference("abc", "ab") = ""
* StringUtils.difference("ab", "abxyz") = "xyz"
* StringUtils.difference("abcde", "abxyz") = "xyz"
* StringUtils.difference("abcde", "xyz") = "xyz"

82.indexOfDifference()

描述1:回傳兩個字符序列cs1、cs2開始不同的位置,

* StringUtils.indexOfDifference(null, null) = -1
* StringUtils.indexOfDifference("", "") = -1
* StringUtils.indexOfDifference("", "abc") = 0
* StringUtils.indexOfDifference("abc", "") = 0
* StringUtils.indexOfDifference("abc", "abc") = -1
* StringUtils.indexOfDifference("ab", "abxyz") = 2
* StringUtils.indexOfDifference("abcde", "abxyz") = 2
* StringUtils.indexOfDifference("abcde", "xyz") = 0

描述2:比較陣列中所有的字符序列,并回傳開始不同的位置,

* StringUtils.indexOfDifference(null) = -1
* StringUtils.indexOfDifference(new String[] {}) = -1
* StringUtils.indexOfDifference(new String[] {"abc"}) = -1
* StringUtils.indexOfDifference(new String[] {null, null}) = -1
* StringUtils.indexOfDifference(new String[] {"", ""}) = -1
* StringUtils.indexOfDifference(new String[] {"", null}) = 0
* StringUtils.indexOfDifference(new String[] {"abc", null, null}) = 0
* StringUtils.indexOfDifference(new String[] {null, null, "abc"}) = 0
* StringUtils.indexOfDifference(new String[] {"", "abc"}) = 0
* StringUtils.indexOfDifference(new String[] {"abc", ""}) = 0
* StringUtils.indexOfDifference(new String[] {"abc", "abc"}) = -1
* StringUtils.indexOfDifference(new String[] {"abc", "a"}) = 1
* StringUtils.indexOfDifference(new String[] {"ab", "abxyz"}) = 2
* StringUtils.indexOfDifference(new String[] {"abcde", "abxyz"}) = 2
* StringUtils.indexOfDifference(new String[] {"abcde", "xyz"}) = 0
* StringUtils.indexOfDifference(new String[] {"xyz", "abcde"}) = 0
* StringUtils.indexOfDifference(new String[] {"i am a machine", "i am a robot"}) = 7

83.toEncodedString()

描述:使用指定的編碼,將位元組陣列轉化為字串,

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/242886.html

標籤:python

上一篇:Python基礎(上篇)

下一篇:numpy

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more