I seem to be stuck trying to replace the last comma with “&” using replace. Is this possible?
Example 1: name1, name2, name 3
Example 2: name 1, name 2
The outcome I’m after is
Example 1: name1, name2 & name3
Example 2: name1 & name2
Thank you!
I seem to be stuck trying to replace the last comma with “&” using replace. Is this possible?
Example 1: name1, name2, name 3
Example 2: name 1, name 2
The outcome I’m after is
Example 1: name1, name2 & name3
Example 2: name1 & name2
Thank you!
Hi @inthemaking
You can apply following method to achieve this:
{{replace(join(add(remove(split(167.text; “,”); last(split(167.text; “,”))); “and” + space + last(split(167.text; “,”))); “,”); “,and”; space + “and”)}}
Text: name 1,name 2, name 3
And the output is:
Regards,
Msquare Automation - Gold Partner of Make
Visit us here | Youtube Channel
Welcome to the Make community!
Yes, you can do this with the replace function only.
e.g.:
{{replace(49.example; "/, ([^,]+)$/"; " & $1")}}
Example:
Output:
For more information, see the “replace” function documentation in the Help Center.
Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —
parseDate
| Tokens for formatDate
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
{
"subflows": [
{
"flow": [
{
"id": 1,
"module": "util:ComposeTransformer",
"version": 1,
"parameters": {},
"mapper": {
"value": "{{replace(49.example; \"/, ([^,]+)$/\"; \" & $1\")}}"
},
"metadata": {
"designer": {
"x": 247,
"y": -830
}
}
}
]
}
],
"metadata": {
"version": 1
}
}
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
Ahh I was about 3/4 of the way there, missed the last part. Thank you!
No problem, glad I could help!
1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.
2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.
This marks the topic as solved, so that:
To do this, simply click the checkbox at the bottom of the post that answers your question:
3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!
4. Do join the unofficial Make Discord server for live chat and video assistance
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!