Forum Discussion
Yes!! This is so much better. I 100% agree with you on the tightening up of the search criteria. That’s initially what I attempted to do, but kept failing miserably at. I like your solution much better. Looking at your version, I think I might have been overthinking syntax and adding in too many escape backslashes in my original attempts.
I will go through your solution and get familiar with it. I still don’t understand how the (_matchid, prefix, b4enc) function is working as I don’t see any explicit function being called, but only parameters and arguments. I tried Googling this so that I could learn about how you built this expression, but I had a hard time finding something that resembled this scenario. Maybe you can try and explain it to me if it won’t take too much of your time.
Thanks so much for refining my work and helping to make me a better developer.
Alex
Here is some documentation on the String replace function (our docs). If you google “Javascript String replace” you’ll get many hits.
The replacer function that we pass to replace() will be passed these parameters:
-
The first parameter will be the matched substring (ex: _matched).
-
The parameters after that will correspond to any parenthesized groupings. We just so happen to define two groupings for each regex, so we know that we’ll be passed two parameters for each of these expressions. We could call these whatever, p1 and p2 for example. We used more meaningful names.
Per the docs, we will also be passed an offset and the original string, if added those parameters. I haven’t tested this. Original string would be quite large. I’m not a JavaScript expert, and continue to be impressed with the power of SnapLogic’s expression language.
- alex_panganiban4 years agoContributor
Awesome explanation! Thanks very much!