I have a WSDL (portion show below), from which I am trying to retrieve the names of all string elements using a regular expression.
<xs:element minOccurs="0" name="appCurrDpId" type="xs:string" />
<xs:element minOccurs="0" name="appCustomerCapable" type="xs:string" />
<xs:element minOccurs="0" name="appDateReceivedSys" type="xs:date" />
<xs:element minOccurs="0" name="appDecision" type="xs:string" />
<xs:element minOccurs="0" name="appPriority" type="xs:int"/>
<xs:element minOccurs="0" name="appCountry" type="xs:string" />
So I have a regex that matches the lines on which only the string elements occur:
name="(.*?)"\s?type="xs:string
But I am only interested in the portion enclosed by the first set of brackets (a group, right?), i.e. in the name attribute.
UPDATE:
The answers below have exposed a flaw in my understanding: I thought that being able to return a portion of a regular expression (as determined by a group) is a feature of a regular expression, which obviously it is not. It is more of a “side-effect”, and one that requires more complex processing.
In my case, I was hoping to be able to do this in my text editor (Sublime Text), because of the nifty ability to highlight and select all search results.
Anyway, thanks for the answers.
As you don’t say which language you’re using, here a way to do it in perl:
output: