I'm trying to use regex in freemarker pdf template...
# advancedpdf
b
I'm trying to use regex in freemarker pdf template to replace line break to comma. If I use string from the field regex works fine but if I use it from record field it doesn't work.
Copy code
<#assign text = "Testing 
Testing2, 
Testing3" />
<#assign cleaned_text = text?replace("[\\r\\n]+", ",", "r")>
${cleaned_text}
Then it shows as expected
Copy code
Testing
Testing2, Testing3
However I have a field with same text but if I assign that value it doesn't work.
Copy code
<#assign text = record.custfield_id />
<#assign cleaned_text = text?replace("[\\r\\n]+", ",", "r")>
${cleaned_text}
This shows the original text. How to solve this problem?
g
what happens when you print
${record.custfield_id?html}
? Does it return any characters for the line break?
s
I think that Netsuite may be automatically replacing line break characters with HTML line break tags, so even though it’s \r\n in the original field, it may be converted to a BR tag within the template.
👍 1