2013年9月26日星期四

String parsing

For example the string : iloveAVdata [221] xxdata [ab] -> iloveAV221xxab. Both the string all the data [*] -> *, seeking ideas
------ Solution ---------------------- ----------------------
regular expressions , replaceAll
I love AV data?
------ Solution - -------------------------------------------
		String str = "youloveAVdata[221]xxdata[ab]";
str = str.replaceAll("\\[(.+?)\\]", "$1");
System.out.println(str);
< br> ------ For reference only ---------------------------------------


String str = "youloveAVdata[221]xxdata[ab]";
str = str.replaceAll("data\\[(.?)\\]", "$1");
System.out.println(str);


positive solution , a little less "data", it may be data [], I did not mention
------ For reference only ------------ ---------------------------

+1
------ For reference only - -------------------------------------
bright ,
- ---- For reference only ---------------------------------------
< br />

String str = "youloveAVdata[221]xxdata[ab]";
//+改成*
str = str.replaceAll("\\[(.*?)\\]", "$1");
System.out.println(str);

------ For reference only ----------------------------------- ----
replaceAll ("data [", ""); replaceAll ("]", ""); so what is the problem you

没有评论:

发表评论