我有一个字符串如下:-
string= "None I am using a new technology test"
我已经使用了 split [
string.split(" ")
],但无法在我的输出应该是的地方编写 reg ex
Str_output= "I am using a new technology"
基本上必须排除字符串的第一个和最后一个单词。
string.split(" ")[1]+string.split(" ")[2]+string.split(" ")[3]
等等
这种和平的代码应该有效
String s= "None I am using a new technology test";
Pattern p = Pattern.compile("^\\w+\\s(.*)\\s\\w+$");
Matcher m = p.matcher(s);
m.find();
System.out.println(m.group(1));
^\\w+\\s
匹配第一个单词
\\s\\w+$
匹配最后一个单词
.*
剩下的