- String s3 = "Real-How-To";
- String [] temp = null;
- temp = s3.split("-");
- etShow.setText(temp[0] + " linc " + temp[1]);
但是要注意的是,如果使用"."、"|"、"^"等字符做分隔符时,要写成s3.split("//^")的格式,
否则不能拆分。
参见http://www.rgagnon.com/javadetails/java-0438.html
中
split() is based on regex expression, a special attention is needed with some characters which have a special meaning in a regex expression.
For example :
- String s3 = "Real.How.To";
- ...
- temp = s3.split("//.");
- or
- String s3 = "Real|How|To";
- ...
- temp = s3.split("//|");