Question

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 ideas how to get round this?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top