小编kap*_*kar的帖子

如何在XSLT 1.0中使用正则表达式?

我正在使用XSLT 1.0.我的输入信息可能包含这些值

<!--case 1-->
<attribute>123-00</attribute>

<!--case 2-->
<attribute>Abc-01</attribute>

<!--case 3-->
<attribute>--</attribute>

<!--case 4-->
<attribute>Z2-p01</attribute>
Run Code Online (Sandbox Code Playgroud)

我想找出符合条件的字符串:

if string has at least 1 alphabet AND has at least 1 number,
then 
do X processing
else
do Y processing
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,对于情况1,2,4我应该能够进行X处理.对于案例3,我应该能够进行Y处理.

我的目标是使用正则表达式(在XSLT 1.0中).

对于所有情况,该属性可以采用任何长度的任何值.

我尝试使用match,但处理器返回错误.我尝试使用translate函数,但不确定是否使用正确的方法.

我在考虑.

if String matches [a-zA-Z0-9]* 
then do X processing
else
do y processing.
Run Code Online (Sandbox Code Playgroud)

如何使用XSLT 1.0语法实现它?

regex xslt

17
推荐指数
1
解决办法
4万
查看次数

标签 统计

regex ×1

xslt ×1