加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 如何在XSLT中使用fn:replace(string,pattern,replace)

发布时间:2020-12-16 07:47:10 所属栏目:百科 来源:网络整理
导读:如何使用 fn:replace(string,pattern,replace) 在XSLT中 它是否像 FN:替换(...)/ ?? 该函数指定如下: fn:replace($input,$pattern,$replacement,[$flags])$input xs:string? the string to change$pattern xs:string regular expression to match the area
如何使用
fn:replace(string,pattern,replace)

在XSLT中

它是否像< FN:替换(...)/> ??

该函数指定如下:
fn:replace($input,$pattern,$replacement,[$flags])

$input        xs:string?  the string to change
$pattern      xs:string   regular expression to match the areas to be replaced
$replacement  xs:string   the replacement string
$flags        xs:string   flags for multiline mode,case insensitivity,etc
return value  xs:string

请注意,$pattern是一个regular expression,替换字符串也有一些特殊的替换语法.

这里有些例子:

# simple replacement
replace('query','r','as')               queasy

# character class
replace('query','[ry]','l')             quell

# capturing group substitution
replace('abc123','([a-z])','$1x')       axbxcx123

# practical example
replace('2315551212',(231) 555-1212
    '(d{3})(d{3})(d{4})','($1) $2-$3'
)

参考

> xqueryfunctions.com – Strings – fn:replace
> w3.org/XPath Functions – fn:replace,Flags
> regular-expressions.info – 一个很好的教程

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读