我想从字符串的开头删除'a'
或'the'
,从字符串的结尾删除'checklist'
或'procedures?'
:
输入示例:
A Detailed procedure
The flight checklist
Takeoff procedures
所需输出分别为:
Detailed
flight
Takeoff
使用可变
<xsl:sequence select="replace($string, '^(a|the)\s(.*)\s(procedures?|checklist)$', '$2', 'i')" />
返回完整的$string
,但
<xsl:sequence select="replace('A flight checklist', '^(a|the)\s(.*)\s(procedures?|checklist)$', '$2', 'i')" />
返回flight
。
1条答案
按热度按时间ruarlubt1#
我会尝试
replace($string, '(^(a|the))|((procedures?|checklist)$)', '', 'i')
或replace($string, '(^(a|the)\s)|(\s(procedures?|checklist)$)', '', 'i')
。