根据所需长度拆分字符串 [英] Splitting of strings based on the required length

查看:34
本文介绍了根据所需长度拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以根据所需的长度拆分字符串?例如,我有一个字符串:

Is there an easy way on how to split a string based from the required length? For example, I have a string:

<数据>AAAAABBBBB1111122222RRRRR<数据>

我想填充这样的输出:

AAAAA
BBBBB
11111
22222
RRRRR

谢谢.

推荐答案

您可以使用 analyze-string 分解数据:

You can use analyze-string to break up the data:

<xsl:template match="Data">
    <xsl:variable name="tokens" as="xs:string*">
        <xsl:analyze-string select="." regex=".{{1,5}}">
            <xsl:matching-substring>
                <xsl:sequence select="."/>
            </xsl:matching-substring>
        </xsl:analyze-string>
    </xsl:variable>
    <xsl:value-of select="$tokens" separator="&#10;"/>
</xsl:template>

这篇关于根据所需长度拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆