Warm tip: This article is reproduced from serverfault.com, please click

Removing special characters in field name using groovy

发布于 2020-12-01 00:12:12

I have a field <Age (D.O.B)>.I want the result to be i,e Age in brackets (unable to see my tag here)

I am using groovy.Please help.

I tried escaping the characters but unable to.

def msgBodyModified21 = msgBodyOriginal.replaceAll('<Age'+\\s+'(D.O.B)>', '<Age>')

Questioner
Sam
Viewed
0
cfrick 2020-12-01 14:29:28

Your quoting on the regexp is wrong. Use:

"<Age (D.O.B)>".replaceAll(/<Age\s+\(D\.O\.B\)>/, "<Age>")