Clean Emoji before going into MySQL

I am having issues where I cannot remove emojis from a webhook going into a MySQL database. I have followed the advice here Remove emoji from a string - #9 by samliew using the JavaScript provided (modified to meet my scenario) and the regex, along with variants of Regex, but no luck.

Someone submitted text with the following emojis:

:upside_down_face: :expressionless:

And the error I get is:

Incorrect string value: β€˜\xED\xA0\xBD\xED\xB9\x83…’

Any suggestions?

Welcome to the Make community!

When reaching out for assistance with your regex pattern for a Text Parser module, it would be super helpful if you could share the actual text you’re trying to match. Screenshots of text can be a bit tricky, so if you could copy and paste the text directly here, that would be awesome! It ensures we can run it against test patterns effectively. If there’s any sensitive info, feel free to change it to something fictional yet still valid by keeping the format intact.

Providing clear text examples saves time on both ends and helps us give you the best possible solution. Without proper examples, we might end up playing a guessing game, and nobody wants that as it is a waste of time! You are more likely to get a correct answer faster. So, help us help you by sharing those text snippets. Thanks a bunch!

samliew – request private consultation

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

1 Like

Hi @samliew I’ve tried a few variants. I currently have it set up with the Regex:


I have also tried a JavaScript module with:

// Function to remove emojis
function removeEmojis(input) {
  const emojiRegex = /([\u2700-\u27BF]|[\uE000-\uF8FF]|[\uD800-\uDFFF][\uDC00-\uDFFF])/g;
  return input.replace(emojiRegex, '');

// Define the prefixes to check
const prefixes = ["Any comments on these pages", "Your comments", "Any feedback"];

// Assuming 'inputData' is the object containing your form submission fields
let data = inputData; // Replace 'inputData' with the actual input object from your webhook

// Iterate over each field in the data object
for (let key in data) {
  if (data.hasOwnProperty(key)) {
    // Check if the key starts with any of the specified prefixes
    for (let prefix of prefixes) {
      if (key.startsWith(prefix)) {
        // Clean the field by removing emojis
        data[key] = removeEmojis(data[key]);
        break; // Break the loop as we found a matching prefix

// Output the cleaned data object
outputData = data;