Hi guys!
I'm trying to convert a string into a slug, and I need to replace polish diacritics with standard Latin characters. Should I use the regex_replace() formula? If yes, which expression should I pick in this case?
Hi guys!
I'm trying to convert a string into a slug, and I need to replace polish diacritics with standard Latin characters. Should I use the regex_replace() formula? If yes, which expression should I pick in this case?
Hi! 😊
I'm sure you've likely found a solution that works for you by now - but I just created a formula for this in my own base & thought I'd share just in case anyone else comes across this post searching for an example.
Below are the diacritic characters I needed, but if you need more you can find a full list of characters here.
REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE({{your_field}}, '[àÀáÁâÂãÃäÄåÅæÆ]', 'a'), '[èÈéÉêÊëË]', 'e'), '[ìÌíÍîÎïÏ]', 'i'), '[ñÑ]', 'n'), '[øØœŒöÖõÕôÔóÓÒò]', 'o'), '[ùÙúÚûÛüÜ]', 'u'), '[ðÐ]', 'd'), '[çÇ]', 'c'), '[ÿŸýÝ]', 'y'), '[ß]', 's'), '[^A-Za-z0-9]+',"")
*please note, my formula also replaces special characters - if you don't need to do so, just replace the last expression or use this formula:
REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE(REGEX_REPLACE({{your_field}}, '[àÀáÁâÂãÃäÄåÅæÆ]', 'a'), '[èÈéÉêÊëË]', 'e'), '[ìÌíÍîÎïÏ]', 'i'), '[ñÑ]', 'n'), '[øØœŒöÖõÕôÔóÓÒò]', 'o'), '[ùÙúÚûÛüÜ]', 'u'), '[ðÐ]', 'd'), '[çÇ]', 'c'), '[ÿŸýÝ]', 'y'), '[ß]', 's')
Just thought I would add my formula to this post here as I needed to maintain whether the character was upper case or lower case as I was removing diacritics from Vietnamese placenames as part of a paragraph structure.
I was good to build on the formula above and I just use UPPER and LOWER on my list of Vietnamese characters to be able to easily have a list for either format. I kept the European diacritics in the formula from above just in case that ever become neccessary for us, then it was alredy done.
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
REGEX_REPLACE(
{{You field name}},
'[ÀÀÁÁÂÂÃÃÄÄÅÅÆÆẢÁẠÀẢÃĂẮẶẰẲẴÂẤẬẦẨẪÁẠÀẢÃĂẮẶẰẲẴÂẤẬẦẨẪ]', 'A')
,
'[ààááââããääååææảáạàảãăắặằẳẵâấậầẩẫáạàảãăắặằẳẵâấậầẩẫ]', 'a'),
'[ÈÈÉÉÊÊËËÉẸÈẺẼÊẾỆỀỂỄÉẸÈẺẼÊẾỆỀỂỄ]','E'),
'[èèééêêëëéẹèẻẽêếệềểễéẹèẻẽêếệềểễ]', 'e'),
'[ÌÌÍÍÎÎÏÏÍỊÌỈĨÍỊÌỈĨ]', 'I'),
'[ììííîîïïíịìỉĩíịìỉĩ]', 'i'),
'[ØØŒŒÖÖÕÕÔÔÓÓÒÒÓỌÒỎÕÔỐỘỒỔỖƠỚỢỜỞỠÓỌÒỎÕÔỐỘỒỔỖƠỚỢỜỞỠ]', 'O'),
'[øøœœööõõôôóóòòóọòỏõôốộồổỗơớợờởỡóọòỏõôốộồổỗơớợờởỡ]', 'o'),
'[ÙÙÚÚÛÛÜÜÚỤÙỦŨƯỨỰỪỬỮÚỤÙỦŨƯỨỰỪỬỮ]', 'U'),
'[ùùúúûûüüúụùủũưứựừửữúụùủũưứựừửữ]', 'u'),
'[ÐÐĐĐ]', 'D'),
'[ððđđ]', 'd'),
'[ŸŸÝÝÝỴỲỶỸÝỴỲỶỸ]', 'Y'),
'[ÿÿýýýỵỳỷỹýỵỳỷỹ]', 'y')
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.