-3

我有我要解析的字符串 newstr:

[( ?A = <http://www.semanticweb.org/vassilis/ontologies/2013/5/Test#Hello> ), ( ?A = <http://www.semanticweb.org/vassilis/ontologies/2013/5/Test#World> )]

使用下面显示的代码,我得到了这个结果:

[#Hello>, #World>]

我应该改变什么来获得:

Hello, World

代码:

List<String> strlist = new ArrayList<String>() ;

                  Pattern p = Pattern.compile("#([^>]+)>");
                   Matcher m = p.matcher(newstr);


                   while (m.find()) {
                       strto.add(m.group());
                    }



    System.out.println(strtogams);
   String[] strto2 = strto.toArray(new String[20]) ;
4

1 回答 1

0

如果 Java 可以查看断言,也许是这样的:

 (?<=\#)[^>]+

Ps - 我没有看其他问题(应该有,但是..)

于 2013-09-17T20:28:00.523 回答