这是
<#elseif (pageData.author.googlePlus)[0]=="+" || (pageData.author.googlePlus)?
matches("^[+]+")>
<#assign str = (pageData.author.googlePlus)?replace("^[+]+","")>
<link rel="author" href="https://plus.google.com/+${(str)!}/posts" />
<#else>
这有什么问题?我想要这样的东西
Input: +xyz
Output: +xyz
Input: ++xyz
Output: +xyz
Input: +++xyz
Output: +xyz
答案 0 :(得分:7)
问题是您缺少"r"
参数。这样做:?replace("^[+]+", "", "r")
答案 1 :(得分:0)
在caracter类[]中插入^:
[^+]+
结果:
+++xyz
Match 1: xyz 3 3
不在范围内的字符可以通过补充来匹配 集合。如果集合的第一个字符是'^',则表示所有字符 不在集合中的将匹配。例如,[^ 5]将匹配 除'5'以外的任何字符,[^^]将匹配任何字符除外 '^'。如果它不是第一个字符,则没有特殊含义 集。