String s = "author= {insert text here},";
试图获取字符串的内部,我环顾四周,但找不到仅使用 split 或 tokenizer 的解决方案...
到目前为止我正在这样做
arraySplitBracket = s.trim().split("\\{", 0);
这让我在此处插入文本}
,
在 array[1] 但 id 就像不附加 }
的方式
也尝试过
StringTokenizer st = new StringTokenizer(s, "\\{,\\},");
但它给了我 author=
作为输出。
最佳答案
public static void main(String[] args) {
String input="{a c df sdf TDUS^&%^7 }";
String regEx="(.*[{]{1})(.*)([}]{1})";
Matcher matcher = Pattern.compile(regEx).matcher(input);
if(matcher.matches()) {
System.out.println(matcher.group(2));
}
}
关于java - 使用 split 或 tokenizer 将字符串放入大括号内的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53058126/