I’m not sure why this isn’t built into Bubble, but…
I have this regex for find/replace to slugify a text string:
find /\W+/g replace with -
This works well. The problem is I need to tweak it to replace multiple hyphens with a single hypen. I tried a simple find “—” replace “-” and that didn’t work.
+1 it’d be great to have a text:formatted as slug function that does this. It’d be ok if it couldn’t check for duplicates etc but for typical cases like replacing space with hyphens & replacing characters like ‘&’ with ‘and’ would make it so much easier
Thanks. That helps clean up my process. In the end I had to generate a formatted text string that I then feed into the Set a thing’s slug workflow action.
Fyi for anyone looking to generate clean slugs, I generated the input text string as follows using chained find-replaces functions:
Replace ’ with empty = Remove apostrophes Replace & with and = Convert ampersand Replace [^0-9a-zA-Z&]+ with dash = convert special chars to dashes Replace (-)\1+ with dash = replace 2 or more dashes with a single dash Replace (?<!\S)-|-(?!\S) with empty = trim any leading or trailing dashes
I really do think @Bubble should do this for us as part of its built-in slugify function.
Agreed. See in the thread what I had to figure out and implement. Bubble should be able to do this for us so the skugs they create are always perfect slugs.
Good evening,
to solve this situation on bubble and clean up any string to create a perfect slug, I developed a plugin that could help you.
I was myself stuck on a marketplace to succeed in cleaning accents and special characters.
I hope the demo page will help you to understand how to clean your strings efficiently.
HUGE timesaver… huge. I was able to set up a backend workflow and cruise through almost 2500 records and get perfectly formatted slugs for all of them. Thank you!