/** * Class Function Description * @version * @author Flyer March 12, 2018 PM 5:41:08 * @since 1.8 * * public class Matchstrutil { /** * @param args */public static void main (string[] args) {String Srctext = "[{Voice=bo
Ytype, picture=http://xxj.jpg},{voice=, picture=123.jpg}] "; String findText = "Picture";
The ending string is "}" list<string> r1 = Appearkey (Srctext, FindText, "}");
SYSTEM.OUT.PRINTLN (R1); String findText1 = "Voice";
The ending string is "," list<string> R11 = Appearkey (Srctext, FindText1, ",");
System.out.println (R11); /** * Gets the value corresponding to the specified string * * @param srctext Source String * @param findText the string to find * @param endstr with what character
String End * @return */public static list<string> Appearkey (String srctext, String findtext,string endstr) {
list<string> result =new arraylist<> ();
int count = 0;
Pattern p = pattern.compile (FindText); Matcher m = P.matcher (Srctext); while (M.find ()) {//count++;//System.out.println (M.start ());//The beginning of string occurrences string shen
Gyustr =srctext.substring (M.end () +1);
int firststr = Shengyustr.indexof (ENDSTR);
String value = shengyustr.substring (0,FIRSTSTR);
System.out.println (shengyustr.substring (0,FIRSTSTR));
if (Value!=null &&value.length () >0) {Result.add (value);
}//System.out.println (M.end ());//The end position where the string appears} return result; }
}
Output
[Http://xxj.jpg, 123.jpg] [Boytype]