Eri*_*Kim 2 java string whitespace substring extract
我有一个字符串,其中包含由空格分隔的2个整数,后跟任何包含空格的字符串.
例:
23 14 this is a random string
Run Code Online (Sandbox Code Playgroud)
我该如何提取this is a random string?
整数不保证是两位数,因此我无法弄清楚如何使用indexOf和substring来提取这些数据.
提前致谢.
用途split(String regex, int limit):
String s = "23 14 this is a random string";
String[] arr = s.split(" ", 3);
System.out.println(arr[2]);
Run Code Online (Sandbox Code Playgroud)
OUTPUT:
这是一个随机字符串
| 归档时间: |
|
| 查看次数: |
397 次 |
| 最近记录: |