Add Dashes Between Spaces

Is there a way to take an input such as “this is a question” and store it as “this-is-a-question”. I’m trying to add dashes b/w spaces so I can make a unique url based on a question a user ask.

I am new to Bubble and it’s been a long time since I’ve done other programming, but to do what you’re asking, I would look at regular expressions. It looks like you can use :extract with Regex to extract the input element’s value, replacing spaces with dashes. You’ll need to find an online reference or buy a book to learn how to use regular expressions.

Hopefully someone will chime in to give you the syntax to do a simple text replacement.

Note that to do what you describe, you’ll have other challenges to deal with. For instance, if the user enters a question mark or other special character as part of their question, you’ll need to clean that up or the URL you generate won’t be acceptable.

BTW, when posting a question, it is always helpful to provide more context about how, in your app, you’ll be applying the solution you’re asking about.

Good luck.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.