我有一个免费标记变量${string},它可以是任何长度。如何仅将最后两个字符大写?谢谢
发布于 2011-12-28 05:55:05
您可以在字符串上使用upper_case builtin和sequence slicing,并编写如下所示的FTL函数
<#function foo text>
<#local len = text?length />
<#if (len>2)>
<#return text[0..len-3] + text[len-2..]?upper_case>
<#else>
<#return text?upper_case>
</#if>
</#function>然后是FTL表达式
${foo("foobar")}生成字符串foobAR。
https://stackoverflow.com/questions/8649311
复制相似问题