Forum Discussion
4 Replies
- koryknickEmployee
jfpelletier - Please download the attached zip file and decompress it. Import the SLP and upload the expr file to the same project via Manager. Your regular expressions and replacement strings are in the expr file - note the subtle changes required to the regular expression with the XML tags.
Basically, I'm using the Expression Library to store the regex as an array, then using the Array.reduce() method to spin through that array and process each replacement on the input variable.
Please note that if the number of replacements is very large and the volume of data is also large, you may see a significant CPU load on your execution node. Just something to keep in mind if you have a number of other jobs that need to run at the same time as this process.
Hope this helps!
- jfpelletierContributor
Hello koryknick,
Yes, that's exactly what I needed, it works perfectly for me!
Thanks a million and have a great day!
JF
- alchemizContributor III
Hi jfpelletier,
Good day, you can use regex pattern.
e.g.~EmEm
- jfpelletierContributor
Hello alchemiz,
Thanks a lot for your suggestion, however I'm already using regex patterns (a few actually). More precisely, I'm looking for a way to maybe store the patterns in an associative array, and loop them all to apply them all on the same string. Having the patterns (regex and fixed strings) in an associative array would greatly help with maintenance when more patterns are required.
Example of what I mean (the real list is much longer):
{ "Jan." : "January", "Feb." : "February", "Mon." : "Monday", "<sup>(.*)</sup>" : "\1", "otherRegex" : "replace text" }
Is there a way to store the strings to replace (including regex) in a structure as above and loop through it to have all the replacements done?
Thanks,
JF