Stringutil packet Function Learning __ function

Source: Internet
Author: User
Stringutil Package FunctionStringutil Package function
First, the array is converted into a string:
1, stringutil.convstring (string[] str) converts the characters in the array to a string
STRING[3] s = {"A", "B", "C"}
Stringutil.convstring (s) = "A,b,c"
2. Static public string converstring (string[] str, string splitstr) converts characters in an array to a string to specify character segmentation
STRING[3] s = {"A", "B", "C"};
Stringutil.convstring (S, "@") = "a@b@c";


Two, the null value detection:
3. Stringutils.isempty (string str) determines whether a string is empty and the space is not null-treated. Stringutils.isempty (NULL) = True Stringutils.isempty ("") = True Stringutils.isempty ("") = False Stringutils.isempty (" Bob ") = False Stringutils.isempty (" Bob ") = False
4. public static Boolean IsBlank (String str) determines whether a string is empty and the space is null-treated. Stringutils.isnotblank (NULL) = True Stringutils.isblank ("") = True Stringutils.isblank ("") = True Stringutils.isblank (" Bob ") = False Stringutils.isblank (" Bob ") = False
Iii. non-null processing:
5, Stringutils.isnotempty (String str) to determine whether a string is not empty, the space is not NULL processing. Stringutils.isnotempty (NULL) = False Stringutils.isnotempty ("") = False Stringutils.isnotempty ("") = True stringutils. Isnotempty ("Bob") = True Stringutils.isnotempty ("Bob") = True

6. public static Boolean Isnotblank (String str) determines whether a string is not empty and the space is null-treated. Stringutils.isnotblank (NULL) = False Stringutils.isnotblank ("") = False Stringutils.isnotblank ("") = False stringutils . Isnotblank ("Bob") = True Stringutils.isnotblank ("Bob") = True

Four, space processing
7. public static string trim (string str) formats a space in a string, has a non-null judgment processing stringutils.trim (NULL) = null Stringutils.trim ("") = "" Stringutils.trim ("") = "" Stringutils.trim ("abc") = "abc" Stringutils.trim ("abc") = "abc"

8. public static string Trimtonull (String str)
Formats a space in a string that has non-null judgment processing if NULL stringutils.trimtonull (NULL) = null stringutils.trimtonull ("") = null Stringutils.trimtonull ("") = null stringutils.trimtonull ("abc") = "abc" Stringutils.trimtonull ("abc") = "abc"

9. public static string Trimtoempty (String str) formats a space in a string, has non-null judgment processing, and if NULL returns "" Stringutils.trimtoempty (NULL) = "" String Utils.trimtoempty ("") = "" Stringutils.trimtoempty ("") = "" Stringutils.trimtoempty ("abc") = "abc" Stringutils.trimtoe Mpty ("abc") = "abc"

Five, string comparison:
10, public static Boolean equals (String str1, String str2)
Determines whether two strings are equal, has non-null processing 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

11. public static Boolean Equalsignorecase (String str1, String str2)
Determines whether two strings are equal and has non-null processing. Ignore case stringutils.equalsignorecase (null, NULL) = True Stringutils.equalsignorecase (NULL, "abc") = False stringutils.equ Alsignorecase ("abc", NULL) = False Stringutils.equalsignorecase ("ABC", "abc") = True Stringutils.equalsignorecase ("ABC "," ABC ") = True

Vi. Treatment of IndexOf
12. public static int indexOf (String str, string searchstr)
Returns the location of the string to find, with non-null processing stringutils.indexof (NULL, *) =-1 stringutils.indexof (*, NULL) =-1 Stringutils.indexof ("", "") = 0 Stringutils.indexof ("Aabaabaa", "a") = 0 stringutils.indexof ("Aabaabaa", "B") = 2 Stringutils.indexof ("Aabaabaa", "AB" = 1 Stringutils.indexof ("Aabaabaa", "") = 0

13. public static int indexOf (String str, string searchstr, int startpos)
Returns the location of the string to be looked at at the specified location, with non-null processing stringutils.indexof (NULL, *, *) =-1 stringutils.indexof (*, NULL, *) =-1 Stringutils.indexo F ("", "", 0) = 0 stringutils.indexof ("Aabaabaa", "a", 0) = 0 stringutils.indexof ("Aabaabaa", "B", 0) = 2 stringutils.in  Dexof ("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

Seven, substring processing:
14. public static string substring (string str, int start)
Returns all characters in the string starting at the specified position 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"

15. public static string substring (string str, int start, int end)
Returns the substring between the start position and the end position stringutils.substring (NULL, *, *) = null stringutils.substring ("", *, *) = "" Stringutils.substring ("abc", 0, 2) = "AB" stringutils.substring ("abc", 2, 0) = "" Stringutils.substring ("abc", 2, 4) = "C" Stringutils.subst Ring ("ABC", 4, 6) = "" Stringutils.substring ("abc", 2, 2) = "" Stringutils.substring ("abc",-2,-1) = "B" stringutils.s Ubstring ("abc", -4, 2) = "AB"

16, Substringafter/substringbefore before and after the substring processing: Returns all characters before the specified string 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 "Strin Gutils.substringbefore ("abc", "") = "" Stringutils.substringbefore ("abc", NULL) = "ABC"

17. public static string Substringafter (String str, string separator)
Returns all characters after the specified string Stringutils.substringafter (null, *) = null stringutils.substringafter ("", *) = "" Stringutils.substringa fter (*, NULL) = "" Stringutils.substringafter ("abc", "a") = "BC" Stringutils.substringafter ("ABCBA", "B") = "CBA" Strin Gutils.substringafter ("abc", "C") = "" Stringutils.substringafter ("abc", "D") = "" Stringutils.substringafter ("abc", "" " ) = "ABC"

18. public static string Substringbeforelast (String str, string separator)
Returns all characters before the last specified string stringutils.substringbeforelast (null, *) = null stringutils.substringbeforelast ("", *) = "" Stringut  Ils.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"

19. public static string Substringafterlast (String str, string separator)
Returns all characters after the last specified string stringutils.substringafterlast (null, *) = null stringutils.substringafterlast ("", *) = "" Stringutil S.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") = ""

Eight, replacing (string replacement)
20. public static string replace (string text, String Repl, string with)
Replaces the specified string of the original string with the specified string Stringutils.replace (NULL, *, *) = null stringutils.replace ("", *, *) = "" Stringutils.replace ("ABA ", NULL, NULL) =" ABA "Stringutils.replace (" ABA ", NULL, NULL) =" ABA "Stringutils.replace (" ABA "," a ", null) =" ABA "Str Ingutils.replace ("ABA", "a", "") = "ABA" Stringutils.replace ("ABA", "a", "z") = "ZBZ"
21. public static string replace (string text, String Repl, string with, int max)
Replaces the specified string of the original string with the specified string Stringutils.replace (NULL, *, *, *) = null stringutils.replace ("", *, *, *) = "" Stringutils.repl Ace ("Abaa", NULL, NULL, 1) = "Abaa" Stringutils.replace ("Abaa", NULL, NULL, 1) = "Abaa" Stringutils.replace ("Abaa", "a", NULL, 1) = "Abaa" Stringutils.replace ("Abaa", "a", "", 1) = "Abaa"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.