在 Java 中使用點 (.)分割字串
假設以下內容是我們的字串。
String str = "This is demo text.This is sample text!";
要使用點分隔字串,請在 Java 中使用 split() 方法。
str.split("[.]", 0);以下是完整示例。
示例
public class Demo { public static void main(String[] args) { String str = "This is demo text.This is sample text!"; String[] res = str.split("[.]", 0); for(String myStr: res) { System.out.println(myStr); } } }
輸出
This is demo text This is sample text!
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP