Tk421
Tk421

Reputation: 6418

Freemarker escape regex characters

How do you run this regex in Freemarker ? The \. makes the template to crash.

<#assign clean = raw?replace('resource.([^\.]+)', 'resource.$1', 'r')/>

Upvotes: 2

Views: 1959

Answers (1)

ddekany
ddekany

Reputation: 31122

Use r'resource.([^\.]+)' or 'resource.([^\\.]+)'. Otherwise the problem is that FTL strings also use \ as an escape character (Just like C, Java, etc.), and there's no \. escape.

Upvotes: 2

Related Questions