public class A03
{
public static void main(String[] args)
{
String s = "张三丰 辽宁 1992-5-15 北京xxx胡同 xx号";
// 提取生日,分成3段
int d = s.indexOf("-") - 4;
String s1 = s.substring(0,d);
String s2 = s.substring(d);
System.out.println("d+1:"+s2);
d = s2.indexOf(" ");
String s3 = s2.substring(0,d);
String s4 = s2.substring(d+1);
System.out.println(s1);
System.out.println(s3);
System.out.println(s4);
}
}
{
public static void main(String[] args)
{
String s = "张三丰 辽宁 1992-5-15 北京xxx胡同 xx号";
// 提取生日,分成3段
int d = s.indexOf("-") - 4;
String s1 = s.substring(0,d);
String s2 = s.substring(d);
System.out.println("d+1:"+s2);
d = s2.indexOf(" ");
String s3 = s2.substring(0,d);
String s4 = s2.substring(d+1);
System.out.println(s1);
System.out.println(s3);
System.out.println(s4);
}
}