Tag:array class Replacement post decode reg return param object
/*** replaces some of the specified characters in a string * @param strdata String Raw String * @param regex string to be replaced by * @param replacement string Substitution String * @return S Tring replaced string */public static string replacestring (string strdata, string regex, string replacement) {if (strdata = = Nu LL) {return null; } int index; index = Strdata.indexof (regex); String strnew = ""; if (index >= 0) {while (index >= 0) {strnew + = strdata.substring (0, index) + replacement; Strdata = strdata.substring (index + regex.length ()); index = Strdata.indexof (regex); } strnew + = Strdata; return strnew; } return strdata;} /*** replaces the special character in the string */public the static string encodestring (String strdata) {if (strdata = null) {return ""; } strdata = Replacestring (Strdata, "&", "&"); Strdata = replacestring (Strdata, "<", "<"); Strdata = replacestring (strdata, ">", ">"); Strdata = replacestring (strdata, "'", "'"); Strdata = ReplacesTring (strdata, "\ \", "\\\\");//The Escape of the slash//strdata = replacestring (strdata, "\", "" "); Double quotes This may not be a special character return strdata;} /*** restores a special character in a string */public static string decodestring (String strdata) {strdata = replacestring (Strdata, "<", "<"); Strdata = replacestring (strdata, ">", ">"); Strdata = replacestring (strdata, "'", "'"); Strdata = replacestring (Strdata, "" "," \ ""); Strdata = replacestring (Strdata, "&", "&"); return strdata;}
JSON background processing of special character methods, processed at Jsonarray.fromobject conversion