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.
精彩评论