Reputation: 171
I would like to remove 'a'
or 'the'
from the beginning of a string, and 'checklist'
or 'procedures?'
from the end of a string:
input examples:
A Detailed procedure
The flight checklist
Takeoff procedures
Desired output, respectively:
Detailed
flight
Takeoff
Using a variable
<xsl:sequence select="replace($string, '^(a|the)\s(.*)\s(procedures?|checklist)$', '$2', 'i')" />
is returning the complete $string
but
<xsl:sequence select="replace('A flight checklist', '^(a|the)\s(.*)\s(procedures?|checklist)$', '$2', 'i')" />
returns flight
as expected.
Upvotes: 0
Views: 23
Reputation: 167716
I would try replace($string, '(^(a|the))|((procedures?|checklist)$)', '', 'i')
or perhaps replace($string, '(^(a|the)\s)|(\s(procedures?|checklist)$)', '', 'i')
.
Upvotes: 2