下面是
<#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发布于 2014-04-01 07:07:14
问题是您缺少"r"参数。这样做:?replace("^[+]+", "", "r")
发布于 2014-04-01 04:45:35
在caracter类[]中插入^:
[^+]+
结果:
+++xyz
Match 1: xyz 3 3不在范围内的
字符可以通过对集合进行补充来匹配。如果集合的第一个字符是'^',则将匹配不在集合中的所有字符。例如,^5将匹配除“5”之外的任何字符,^^将匹配除“^”之外的任何字符。如果^不是集合中的第一个字符,则没有特殊意义。
https://stackoverflow.com/questions/22771736
复制相似问题