Our Amazon Integration App needs to look up the item SKU in Amazon before importing the order. We have different naming conventions in this Amazon, so I need to use RegEx on the returned result to translate the name to our actual SKU. In Amazon export, we use a space in the SKU name, and SKU is appended with "-FBA". I need to replace the first space with a dash (-), and remove the "-FBA" from the end.
For example, I need to translate a name like this:
12223 4556-FBA
To this:
12223-4556
I've been trying to use handlebars to complete this, but I'm not sure if it's possible to replace multiple different matches in the same handlebar. These two formulas work on their own, but I would need to combine them:
I found a workaround to this problem - I was able to use regex to grab the first half of the SKU before the space, regex to grab the second half between the space and "-FBA", and join them together with "-" to get the value I wanted. Here is the handlebar:
Note that the above also did not work in the flow (resulted in invalid quantifier "?"), but it worked in the dev playground .
For anyone else wondering, the reason that this error occurs is because Javascript does not support lookahead / lookbehind, and "?" is involved in the process. You will need to find a different way to structure your formula that avoids lookaheads/lookbehinds.
Here is how I reconstructed this formula, and this now works in the flow:
No problem! Do you know why certain things will work in the Dev playground, but not in the flow itself? I was surprised to see that my regex worked when testing, but ended up having to rethink the whole process after trying to put it in place. Sometimes I will notice inconsistencies between Dev playground behavior and flow behavior, and wanted to see if you or anyone has insight as to what causes that.