2013年9月20日星期五

Regular exchange of string position

There are many like this string: " Joe Smith 13109 13012 John Doe "
exchanged : Joe Smith John Doe 09109 09012

------ Solution ------------------------------------ --------
this ?
	public static void main(String[] args) {
String[] str = {"张三13109李四13012","fff00000ddd111111"};
for(String s : str){
s = s.replaceAll("([^\\d]+)(\\d+)([^\\d]+)(\\d+)", "$1$4$3$2");
System.out.println(s);
}
}

------ For reference only ----------------------------------- ----
do not see very obvious rule
------ For reference only ------------------------ ---------------
1L positive solution !!

没有评论:

发表评论