开发者

How do you escape regex strings in Freemarker

I am using the matches string builtin and need to run a regex pattern

(Views:).*?(span>)(.*?)(<\/div)

However, Freemarker freaks out because of the ">" character which is a special character in Freemarker. Any id开发者_运维技巧eas how to get round this?


Use \l for < and \g for >.

Taken from a FreeMarker documentation page which was second item in a Google search for "freemarker escape string".


Oh and be careful trying to parse HTML with regex - with uncontrolled markup it turns difficult very quickly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜