Skip to main content

Formula to replace special characters - slug creation


Show first post

28 replies

Justin_Barrett
Forum|alt.badge.img+20
Karlstens wrote:

Reading through URL encoders this morning - building formulas to parse urls so that I can easily construct associated MS Flows.

Does anyone have a more elegant method of doing this? Would be great if Airtable had additional formulas for this. Another that I’ve always wanted is Base64 encode/decode.

REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE({URL}, 
"%2F", "/"),
"%20", " "),
"%5F", "_")

It sounds like you want the exact opposite of the ENCODE_URL_COMPONENT() function. Right now your method—or a similar one using SUBSTITUTE()—is the only available option.


Karlstens
Forum|alt.badge.img+20
  • Brainy
  • 601 replies
  • July 21, 2022
Justin_Barrett wrote:

It sounds like you want the exact opposite of the ENCODE_URL_COMPONENT() function. Right now your method—or a similar one using SUBSTITUTE()—is the only available option.


Yup, I thought that might be the case. Thanks for confirming - and fingers crossed we can see some more formula love this year.


nico2
Forum|alt.badge.img+1
  • New Participant
  • 1 reply
  • January 21, 2025

I found this formula at the following link:
https://docs.whalesync.com/resources/support/how-to-create-a-slug-field-in-airtable

LOWER(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(TRIM({Name}), "[^a-zA-Z0-9- ]", ""), " ", "-"), "-+", "-") & "-" & RIGHT(RECORD_ID(), 5))

I modified it:
LOWER(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(TRIM({Name}), "[^a-zA-Z0-9- ]", ""), " ", "-"), "-+", "-"))

Then using Airtable's AI I modified the formula and added the accent substitution:

LOWER(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TRIM({Name}), "Á", "A"), "É", "E"), "Í", "I"), "Ó", "O"), "Ú", "U"), "á", "a"), "é", "e"), "í", "i"), "ó", "o"), "ú", "u"), "[^a-zA-Z0-9- ]", ""), " ", "-"), "-+", "-"))

Reply