/** * @title Remove null values in the string ', ' as a delimiter * gets the individual fields from the database when its value is ', ' * * *, ' * *, ', ' "," * * * "' when, * This method can be used to remove the first delimiter and the empty part of the data, * The string into the normal data string ' ' * * * *, ' * * * ', ' * * * ' ' * @param STR: string to convert * @return */ public string strchange (STRING STR) { Return strchange (str,null); } /** * @title Remove null values in a string * the individual fields obtained from the database, when their valuesFor ', ' * * * ', ' * * * ', ' ', ' * * * ' when, * can use this method to remove the first delimiter and the empty part of the data, * the string into the normal data string ' ' * * * *, ' * * * ', ' * * * ' ' * @param  STR: String to convert * @param split : delimiter (default = ', ') * @return */ public string strchange (string str,string split) {        //1, If the separator is empty, the default is ', ' if (split.trim () = = "" | | split == null) { split= " , ";         }        //2, Convert a string to an array sTring[] arr=str.split (split);         //3, defining intermediate variables value string value= "";         //4, Iterates through the array, adding it to value if the subscript index corresponds to a value of null or an empty string for (string S : arr) { // Note: If the string is judged to be empty, be sure to trim () because: " " .length != 0 if (S!=null && s.trim (). IsEmpty ()) value+=s+split;        }        //5, if value is empty, Returns null, not empty, then the last character of value is removed and then returned to return value==null?null: Value.substring (0, value.length ()-1); }
This article is from the "9891958" blog, please be sure to keep this source http://9901958.blog.51cto.com/9891958/1662427
Java script: Remove the empty string value