正则表达式:Java在xml标记之间提取内容

时间:2015-10-30 16:51:05

标签: java regex xml

我有一个xml字符串

Traceback (most recent call last):
  File "exploitsearch.py", line 26, in <module>
    print exploit.search('query')
  File "/usr/local/lib/python2.7/dist-packages/shodan/client.py", line 79, in search
    return self.parent._request('/api/search', query_args, service='exploits')
AttributeError: 'str' object has no attribute '_request'

我希望使用正则表达式来提取客户端标记和存储在变量中的内容。目前我有

<client>12345abcde</client>

但这似乎不起作用。

1 个答案:

答案 0 :(得分:0)

Matcher m =   Pattern.compile(".*<client>(.*)<\\/client>.*").matcher("<client>12345abcde</client>"); 
m.matches(); 

String value = m.group(2);