描述
${foo}
此正则表达式将找到不在<c:.... test="${foo}" />
块内的裸露
正则表达式:(?!("))\$\{[^}]*\}(?!")
用。。。来代替<c:out value="$0" />

输入文本:<c:if test="${foo man chu}" />${foo bar}more text here
输出文本:<c:if test="${foo man chu}" /><c:out value="${foo bar}" />more text here
要处理可能在 ` 标签内的其他边缘情况,${foo.bar}
您可能需要使用此正则表达式
正则表达式:(?!("))(\$\{[^}]*\})(?!")|(<a\b[^>]*\bhref=")(\$\{[^}]*\})(")
用。。。来代替:$3<c:out value="$1$2$4" />$5

输入文本:<c:if test="${foo man chu}" />${foo bar}more <a href="${foo.name}" />text here
输出文本:<c:if test="${foo man chu}" /><c:out value="${foo bar}" />more <a href="<c:out value="${foo.name}" />" />text here