我希望从SOAP请求中提取Web服务的名称。基本上这些电话看起来像是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.address.com">
<soapenv:Header/>
<soapenv:Body>
<ws:webServiceName>
.
.
.
</ws:webServiceName>
</soapenv:Body>
</soapenv:Envelope>
我尝试了一些正则表达式,但我似乎无法正确地提取名称,我想忽略名称前的<ws:
以及>
字符结束。正则表达式:<ws=([^>]+)
几乎可以使用,但会匹配<ws:webServiceName
任何想法。?感谢
答案 0 :(得分:2)
如果你正在使用的正则表达式支持lookbehinds(在这种情况下是积极的外观,即(?<=...)
),这个应该适合你的需求:
(?<=<ws:)[^>]+