[java] view plaincopy
  1. String s3 = "Real-How-To";  
  2.     String [] temp = null;  
  3.     temp = s3.split("-");  
  4.     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 :

 

[java] view plaincopy
  1. String s3 = "Real.How.To";  
  2. ...  
  3. temp = s3.split("//.");  
  4. or  
  5. String s3 = "Real|How|To";  
  6. ...  
  7. temp = s3.split("//|");  

 

 

相关文章:

  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-30
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
相关资源
相似解决方案