MrTunaDeluxe
MrTunaDeluxe

Reputation: 152

Regex to extract web service name out of SOAP request

I'm looking to pull a the name of a web service from SOAP requests. Basically the calls look something along the lines of:

<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>

I've tried a few regexs but I can't seem to pull just the name correctly, I'd like to ignore the <ws: before the name, as well as the > character at the end. The regex: <ws=([^>]+) almost works, but will match <ws:webServiceName

Any ideas.? Thanks

Upvotes: 0

Views: 1303

Answers (1)

sp00m
sp00m

Reputation: 48807

If the regex flavor you're using supports lookbehinds (in this case positive lookbehinds, i.e. (?<=...)), this one should suit your needs:

(?<=<ws:)[^>]+

Upvotes: 2

Related Questions