It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center。
7年前关闭。
我正在尝试使用带有正则表达式的java中的string.split从母字符串中取出特殊字符串。
我想使用名称,字段和等级作为分隔符。现在,正则表达式应该是什么,以便我的字符串数组(拆分)中包含以下项:
7年前关闭。
我正在尝试使用带有正则表达式的java中的string.split从母字符串中取出特殊字符串。
string str = "name ching chang field computer engineering grade 9.98";
string[] splits = str.split("regex");
我想使用名称,字段和等级作为分隔符。现在,正则表达式应该是什么,以便我的字符串数组(拆分)中包含以下项:
splits[0] = "ching chang"
splits[1] = "computer engineering"
splits[2] = "9.98"
最佳答案
String str = "name ching chang field computer engineering grade 9.98";
String[] splits = str.split("name |field |grade ");
//test with
for(String s : splits)
System.out.println(s);
10-08 12:37