replaceAll string function for replacing special characters

0
Hi, In the documentation I can see that replaceAll function is used for replacing numbers from 0 to 9. However, I need it to replace multiple characters ( if found ) from a given string. The characters that I need replaced are : \, : , / , FW: , RE: , ? , | , * , < , > , &  How do I write these multiple characters in the way the function will understand to search for all of them in the string?   Original example from Mendix docs:  replaceAll('this is a string with no numbers thrown in', '([0-9])', 'NUMBER')   Thanks, Razvan
asked
4 answers
5

You can use a regex here. So [/|*<>] would search on any of these characters.

Regards,

Ronald

 

answered
4

If you like, you can use the RegexReplaceAll java action and replace the Needle Regex input with the characters you would like to replace.

 

answered
0

Getting below error when trying above suggestion.

PatternSyntaxException: Dangling meta character '*' near index 0*

Capture.PNG

answered
0

Hello Razvan Cojocaru,

 

Please use regex '([\\/:?|*<>&]|FW:|RE:)' as shown in below example to remove characters  : \, : , / , FW: , RE: , ? , | , * , < , > , & 

 

Example

replaceAll('FW: Some | example \\ text with / characters to RE: replace?', '([\\/:?|*<>&]|FW:|RE:)', '')forum-88631.png

 

Thanks

answered