Strmen-java is a string processing tool that you can introduce into your project through MAVEN. Strmen-java provides us with a very complete and powerful solution that can be used to solve almost any string processing scenario.
To be able to use Strman-java in your Java application, you can download the package to the Lib directory of your project, and if you are using MAVEN for project management, just add the following dependencies to your pom.xml
list:
Import Strman.
Strman;
Import Java.util.Arrays;
Import java.util.Optional;
/** * Strman-java Package Test uses class * Created by Blinkfox on 16/7/17. * * Public class Strmantest {public static void main (string[] args) {//Append append any number of string strings after a string S1 = Strman
. Append ("F", "O", "O", "B", "A", "R"); System.out.println ("Append:" + S1);
Result => "Foobar"//prepend append any number of strings before a string s1pre = Strman.prepend ("R", "F", "O", "O", "B", "a"); System.out.println ("prepend:" + s1pre); Result => "Foobar"//Appendarray appends a string to an element string in an array of strings S2 = Strman.appendarray ("f", New string[]{"O",
"O", "B", "A", "R"}); System.out.println ("Append:" + s2); Result => "Foobar"//at the corresponding character according to the index of the string.
If the index is a negative number, then the reverse gets, the exception throws the anomaly optional<string> s3 = strman.at ("Foobar", 3); System.out.println ("at:" + s3.get ());
Result => "B"//Between gets an array of strings between the start and end strings string[] S4 = Strman.between ("[ABC], [Def]", "[", "]"); System.out.println ("BetweeN: "+ arrays.tostring (S4));
Result => "[ABC, DEF]"///Chars get a string array of all the characters in a string string[] S5 = Strman.chars ("title"); System.out.println ("chars:" + arrays.tostring (S5)); Result => "[t, I, T, L, E]"//Collapsewhitespace replaces consecutive multiple spaces as a space String s6 = strman.collapsewhitespace ("foo BA
R "); System.out.println ("chars:" + S6); Result => "foo bar"//contains determines whether a string contains another string, and the third argument indicates whether the string case is sensitive Boolean s7 = Strman.contains ("foo bar", "
Foo ");
Boolean S8 = Strman.contains ("foo bar", "foo", false); System.out.println ("contains:" + s7 + "," + S8); Result => "true, true"//Containsall determines whether a string contains all elements of a string array boolean S9 = Strman.containsall ("foo bar", New St
ring[]{"foo", "Bar"});
Boolean s10 = Strman.containsall ("foo bar", New string[]{"foo", "Bar"}, False); System.out.println ("Containsall:" + S9 + "," + S10); Result => "true, true"//Containsany determines whether a string contains any of the elements in a string array boolean S11 = Strman.containsany ("foo bar", new string[]{"FOO", "BAR", "Test"}, False); System.out.println ("Containsany:" + S11);
Result => "true"//COUNTSUBSTR determines the number of a string containing a string long S12 = Strman.countsubstr ("Aaaaaaaaa", "AAA");
Long S13 = Strman.countsubstr ("Aaaaaaaaa", "AAA", false, false); System.out.println ("Countsubstr:" + S12 + "," + S13);
Result => "2, 3"//EndsWith determines whether a string ends with a string of Boolean S14 = Strman.endswith ("foo bar", "Bar");
Boolean S15 = Strman.endswith ("foo bar", "bar", false); System.out.println ("EndsWith:" + S14 + "," + S15); Result => "true, true"//ensureleft ensure that a string begins with a string, and if not, appends the string in front of it, and returns the string results to S16 = Strman.ensureleft ("
Foobar "," foo ");
String S17 = Strman.ensureleft ("Bar", "foo");
String S18 = Strman.ensureleft ("Foobar", "FOO", false);
System.out.println ("Ensureleft:" + S16 + "," + S17 + "," + S18); Result => "Foobar, Foobar, foobar"//ensureright ensure that a string begins with a string and, if not, appends the string in front of it, and returns the string results to string s16r = Strma
N.ensureright ("Foobar", "Bar"); String s17r = strman.ensureright ("foo", "Bar");
String s18r = strman.ensureright ("FooBAR", "bar", false);
System.out.println ("Ensureright:" + s16r + "," + s17r + "," + s18r); Result => "Foobar, Foobar, foobar"//Base64Encode converts a string to a Base64-encoded string s19 = Strman.base64encode ("Strman"
); System.out.println ("Base64Encode:" + s19);
Result => "C3RYBWFU"///Bindecode converts the binary encoding (16-bit) to a string of characters, S20 = Strman.bindecode ("0000000001000001"); System.out.println ("Bindecode:" + S20);
Result => "a"//Binencode converts string characters into binary encodings (16-bit) string S21 = Strman.binencode ("a"); System.out.println ("Binencode:" + S21);
Result => "0000000001000001"//Decdecode converts the decimal encoding (5-bit) to string-character strings S22 = Strman.decdecode ("00065"); System.out.println ("Decdecode:" + S22);
Result => "a"//Decencode converts the string to decimal encoding (5-bit) string s23 = Strman.decencode ("a"); System.out.println ("Decencode:" + s23); Result => ' 00065 '//First gets a string of strings S24 = S from the beginning of the string to the index nTrman.first ("Foobar", 3); System.out.println ("A:" + S24);
Result => ' foo '//Last Gets the string s24l = Strman.last ("Foobar", 3) from the reciprocal index of the end of the string. System.out.println ("Last:" + s24l);
Result => the "bar"//head Gets the string's first character string s25 = Strman.head ("Foobar"); System.out.println ("head:" + S25);
Result => "F"//Hexdecode converts string characters to hexadecimal-encoded (4-bit) string S26 = Strman.hexdecode ("0041"); System.out.println ("Hexdecode:" + S26);
Result => "a"//Hexencode converts the hexadecimal encoding (4-bit) to a string character, S27 = Strman.hexencode ("a"); System.out.println ("Hexencode:" + s27);
Result => "0041"//Inequal tests whether two strings are equal Boolean S28 = Strman.inequal ("A", "B"); System.out.println ("inequal:" + s28);
Result => "true"//Insert inserts a substring at an index of the string s29 = Strman.insert ("Fbar", "oo", 1); System.out.println ("Insert:" + s29);
Result => "Foobar"//Leftpad the string from left until the total length is n string s30 = Strman.leftpad ("1", "0", 5); System.out.println ("Leftpad:" + S30);Result => "00001"//Rightpad the string from right until the total length is n string s30r = Strman.rightpad ("1", "0", 5); System.out.println ("Rightpad:" + s30r); Result => "10000"//LastIndexOf This method returns the index in the call string object that occurred at the last occurrence of the specified value, and searches backwards from the offset for the int s31 = Strman.lastindexof ("Foobarfoo
Bar "," F ", false); System.out.println ("LastIndexOf:" + s31);
Result => "6"//Lefttrim removes all space string s32 = Strman.lefttrim ("Strman") to the left of the strings; System.out.println ("Lefttrim:" + S32);
Result => "Strman"//Righttrim removes all space strings at the far right of the string s32r = Strman.righttrim ("Strman"); System.out.println ("Righttrim:" + s32r); Result => "Strman"//Removeemptystrings removes an empty string from an array of strings string[] S33 = strman.removeemptystrings (new string[]{)
AA "," "," "," BB "," CC ", null});
System.out.println ("removeemptystrings:" + arrays.tostring (S33));
Result => "[AA, BB, CC]"///Removeleft gets rid of the prefix (if present) after the new string s34 = Strman.removeleft ("Foobar", "foo"); System.out.println ("Removeleft:" + s34); // Result => "Bar"//removeright gets rid of the suffix (if present) after the new string s34r = Strman.removeright ("Foobar", "Bar"); System.out.println ("Removeright:" + s34r);
Result => "foo"//Removenonwords get rid of strings that are not characters string s35 = Strman.removenonwords ("foo&bar-"); System.out.println ("removenonwords:" + S35);
Result => "Foobar"//removespaces Remove all space String S36 = strman.removespaces ("str man"); System.out.println ("removespaces:" + s36);
Result => "Strman"//Repeat gets a new string with a given string and number of repetitions, string s37 = Strman.repeat ("1", 3); System.out.println ("repeat:" + s37);
Result => "a"//reverse Gets the inverted string s38 = Strman.reverse ("Foobar"); System.out.println ("Reverse:" + s38); Result => "Raboof"//safetruncate Secure truncated string, not half a word, it always returns the last complete word string s39 = Strman.safetruncate ("a JAVASCR
IPT string manipulation Library. ", 19," ... "); System.out.println ("safetruncate:" + s39); Result => "A Javascript ..."//truncate a less secure truncated string string S40 = strman.truncate ("A Javascript string Manipulation Library.", 19, "..."); SYSTEM.OUT.PRINTLN ("Truncate:" + S40);
Result => "A Javascript str ..."
HtmlDecode the HTML character by inverting the literal String s41 = Strman.htmldecode ("ш"); System.out.println ("HtmlDecode:" + s41);
Result => "ш"//HtmlEncode HTML word escape string s42 = Strman.htmlencode ("ш"); System.out.println ("HtmlEncode:" + s42);
Result => "ш"//Shuffle A string that converts a given string to a random character order s43 = Strman.shuffle ("Shekhar"); System.out.println ("Shuffle:" + s43);
Result => "Rhsheak"//Slugify string (with "-") string s44 = Strman.slugify ("foo bar"); System.out.println ("slugify:" + s44);
Result => "Foo-bar"//transliterate deletes all non valid characters, such as:á=> a String S45 = Strman.transliterate ("Fóõbár"); System.out.println ("transliterate:" + s45);
Result => "foo bar"//surround given "prefix" and "suffix" to wrap a string s46 = Strman.surround ("div", "<", ">"); System.out.println ("Surround:" + s46); ResulT => "<div>"//Tail get rid of the first character string s47 = Strman.tail ("Foobar"); System.out.println ("tail:" + s47);
Result => "Oobar"//Tocamelcase into a hump-style string of strings S48 = Strman.tocamelcase ("Camel case");
String s48_2 = strman.tocamelcase ("Camel-case"); System.out.println ("tail:" + S48 + "," + s48_2);
Result => "CamelCase, CamelCase"//Tostudlycase converted to a studly-style string of strings S49 = strman.tostudlycase ("Hello World"); System.out.println ("tostudlycase:" + s49);
Result => "HelloWorld"//Todecamelize to Decamelize-type string S50 = Strman.todecamelize ("HelloWorld", null); System.out.println ("todecamelize:" + S50);
Result => the "Hello World"//Tokebabcase into a kebab-style string s51 = Strman.tokebabcase ("Hello World"); System.out.println ("tokebabcase:" + s51);
Result => "Hello-world"//Tosnakecase into a snake-style string of strings S52 = strman.tosnakecase ("Hello World"); System.out.println ("tosnakecase:" + s52); Result => "Hello_world"
}
}
The above is the entire content of this article, I hope to be able to learn or work to bring certain help, if there is doubt you can message exchange.