xslt 3 regex in replace函数

voase2hg  于 2023-10-22  发布在  其他
关注(0)|答案(1)|浏览(85)

我想从字符串的开头删除'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

ruarlubt

ruarlubt1#

我会尝试replace($string, '(^(a|the))|((procedures?|checklist)$)', '', 'i')replace($string, '(^(a|the)\s)|(\s(procedures?|checklist)$)', '', 'i')

相关问题