Remove emoji from a string

Similar to this thread:

How can I remove all emoji from a string without manually creating a replace and listing every single emoji? (Not practical)

I’ve tried encoding as URL, but that results in something messy like %F0%9F%87%AF%F0

Thanks!

Text Parser module with regex should work, but I keep running into issues. These all check out with the test tool but aren’t removing emoji

/((\ud83c[\udde6-\uddff]){2}|([\#\*0-9]\u20e3)|(\u00a9|\u00ae|[\u2000-\u3300]|[\ud83c-\ud83e][\ud000-\udfff])((\ud83c[\udffb-\udfff])?(\ud83e[\uddb0-\uddb3])?(\ufe0f?\u200d([\u2000-\u3300]|[\ud83c-\ud83e][\ud000-\udfff])\ufe0f?)?)*)/g
/\p{RGI_Emoji}/gv

Your regex works for me. Perhaps you shouldn’t have put the regex start/end character “/”, as that will be added by the module.

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 90,
                    "module": "regexp:Replace",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "pattern": "(?:(\\ud83c[\\udde6-\\uddff]){2}|([\\#\\*0-9]\\u20e3)|(?:\\u00a9|\\u00ae|[\\u2000-\\u3300]|[\\ud83c-\\ud83e][\\ud000-\\udfff])(?:(?:\\ud83c[\\udffb-\\udfff])?(?:\\ud83e[\\uddb0-\\uddb3])?(?:\\ufe0f?\\u200d(?:[\\u2000-\\u3300]|[\\ud83c-\\ud83e][\\ud000-\\udfff])\\ufe0f?)?)*)+(?:\\s+(?=[-;,.?!]))?",
                        "value": "{{emptystring}}",
                        "global": true,
                        "sensitive": false,
                        "multiline": false,
                        "singleline": false,
                        "text": "{{89.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -857,
                            "y": -1307,
                            "name": "Remove Emojis",
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "expect": {
                                "global": {
                                    "mode": "chose"
                                },
                                "sensitive": {
                                    "mode": "chose"
                                },
                                "multiline": {
                                    "mode": "chose"
                                },
                                "singleline": {
                                    "mode": "chose"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "pattern",
                                "type": "text",
                                "label": "Pattern",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "text",
                                "label": "New value"
                            },
                            {
                                "name": "global",
                                "type": "boolean",
                                "label": "Global match",
                                "required": true
                            },
                            {
                                "name": "sensitive",
                                "type": "boolean",
                                "label": "Case sensitive",
                                "required": true
                            },
                            {
                                "name": "multiline",
                                "type": "boolean",
                                "label": "Multiline",
                                "required": true
                            },
                            {
                                "name": "singleline",
                                "type": "boolean",
                                "label": "Singleline",
                                "required": true
                            },
                            {
                                "name": "text",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

1 Like

Thanks. Yours isn’t working for me with the string:

Berries are HERE! :strawberry::blueberries:

I see issues on the tester too: https://regex101.com/

Those are not emojis, they are text-replaced images by the forum software.

:strawberry::blueberries: gives you :strawberry::blueberries:

1. This forum might have or already changed your text

When pasting text into this forum, you should format the example text using the rich-text editor, otherwise the forum software might modify the displayed text, and you might get incorrect answers from others because of it.

Some things this forum software might do to mangle your text:

– remove extra spaces (which may be necessary)
– convert links to titles (when copied is incorrect)
– incorrect joined links
– convert single and double quotes to smart angled quotes ()
– emojis
– etc.

This interferes with you receiving correct answers, because it:

– makes JSON invalid (you can verify when copy-paste into https://jsonformatter.org)
– makes incorrect text examples when we need to build a pattern for text parsing

2. To prevent this in future, please format text in code blocks

A. Type code fence manually
Either add three backticks ``` before and after the text, like this:

```
content goes here
```

B. Highlight and click the format button
Or use the format code button in the editor:
Screenshot_2023-10-02_191027

3. You might need to re-copy the original text

Once the post has been submitted, it’s too late to format it since it’s already butchered, and you need to make a re-copy of the text, and format it before submitting the forum post.

Please let us know once you have corrected the issue. This will avoid others potentially providing wrong answers based on incorrect text in your question.

Thank you!

1 Like

Sorry, let’s try again

Berries are HERE! 🍓🫐

The character after the strawberry is not a valid emoji.

Screenshot_2024-05-09_100514

Screenshot_2024-05-09_100521

https://regex101.com/r/mF6SWM

([\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D])
1 Like

Hm. It seems to match this?

I’ve revised the regex to

(?:(\ud83c[\udde6-\uddff]){2}|([\#\*0-9]\u20e3)|(?:\u00a9|\u00ae|[\u2000-\u3300]|[\ud83c-\ud83e][\ud000-\udfff])(?:(?:\ud83c[\udffb-\udfff])?(?:\ud83e[\uddb0-\uddb3])?(?:\ufe0f?\u200d(?:[\u2000-\u3300]|[\ud83c-\ud83e][\ud000-\udfff])\ufe0f?)?)*)+

Test: https://regex101.com/r/q1EnMY

Here is the new module export

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 90,
                    "module": "regexp:Replace",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "pattern": "(?:(\\ud83c[\\udde6-\\uddff]){2}|([\\#\\*0-9]\\u20e3)|(?:\\u00a9|\\u00ae|[\\u2000-\\u3300]|[\\ud83c-\\ud83e][\\ud000-\\udfff])(?:(?:\\ud83c[\\udffb-\\udfff])?(?:\\ud83e[\\uddb0-\\uddb3])?(?:\\ufe0f?\\u200d(?:[\\u2000-\\u3300]|[\\ud83c-\\ud83e][\\ud000-\\udfff])\\ufe0f?)?)*)+",
                        "value": "{{emptystring}}",
                        "global": true,
                        "sensitive": false,
                        "multiline": false,
                        "singleline": false,
                        "text": "{{89.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -857,
                            "y": -1307,
                            "name": "Remove Emojis",
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "expect": {
                                "global": {
                                    "mode": "chose"
                                },
                                "sensitive": {
                                    "mode": "chose"
                                },
                                "multiline": {
                                    "mode": "chose"
                                },
                                "singleline": {
                                    "mode": "chose"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "pattern",
                                "type": "text",
                                "label": "Pattern",
                                "required": true
                            },
                            {
                                "name": "value",
                                "type": "text",
                                "label": "New value"
                            },
                            {
                                "name": "global",
                                "type": "boolean",
                                "label": "Global match",
                                "required": true
                            },
                            {
                                "name": "sensitive",
                                "type": "boolean",
                                "label": "Case sensitive",
                                "required": true
                            },
                            {
                                "name": "multiline",
                                "type": "boolean",
                                "label": "Multiline",
                                "required": true
                            },
                            {
                                "name": "singleline",
                                "type": "boolean",
                                "label": "Singleline",
                                "required": true
                            },
                            {
                                "name": "text",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
4 Likes

That worked, thank you!

1 Like

Hi guys, im sending SMS messages via Twilio from make to help manage event schedules from Admin, Coordinator, Instructor, Student & Guardian perspectives. I created semi-canned replies in Airtable with <> tags so the correct & dynamic data can be sent within the Reply.

I added emojis to lots of replies, and they work great, BUT they eat up SMS credits like little emunchkins.

Question: Could i somehow repurpose your Amazing regex to REPLACE any emoji found with the {emoji text} equivalent?

Example :cow2: would be {cow}* or however its coded/stored somewhere in the internets.

*does NOT cause climate change unless Human gets stupid greedy & Industrializes the hapless hoofers.

I actually have 3 sets of replies within each of 10 Voices(Overly Helpful, Angry, Your Mom etc…), each reply is more verbose 3 being most verbose & having the most emojis! Users can choose Voice anytime or select Random.

Im thinking of either ONLY allowing them the least verbose level so i can hand-replace the emojis in that set only
or
hand-replacing all 100+ emojis with the {text-equivalent} in Airtable - luckily its all in one table and not scattered.

Thank you!

Hey there @D_Sparrow :wave:

Just wanted to step in with a piece of friendly advice. Generally, it’s better to create a new topic for your question rather than comment on an older thread that has been solved.

By creating a new topic you’re more likely to receive the proper help from one of our amazing users! This way we also keep the community organized and neat.

Tanks! :sunny:

1 Like

Shot in the dark here but you might have success sending the string to OpenAI using a cheap model (maybe ada) asking it to strip all non text or numerical characters.

Thanks…but im hoping to REPLACE not REMOVE.

You can most likely do the same with proper prompting.

That looks like a new question, could you please create a separate topic for this?

While it’s tempting to hop onto an existing thread, a more effective approach would be to start a new topic just for your question. It helps community experts find and respond to your query quicker, and keeps our space organised for everyone. If you start a new conversation you are also more likely to get help from other users. You can refer others back to a related topic by including that link in your question. Thank you for understanding and keeping our community neat and tidy.

The “New Topic” link can be found in the top-right of the header:

Screenshot_2023-12-19_091207

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!

2 Likes