Variables - can I convert "text string" into "text-string" using an expression?

Hi there, hope someone can help.

In my prototype, I’ve built the following behaviour, to allow me to redirect users to a particular SEO page based on a search term.

  1. User types a town name into a text field and hits “Go”
  2. The town name is passed into a variable, which is then passed into a URL - the user is redirected to the correct page for that town.

So far so good, this is working…but only if the town has a single word name, like “York”. If the town name is “New York” then of course the URL breaks and the user gets a 404.

So the question is:

  • Is it possible to use an expression or other method to turn “new york” into “new-york” before i pass it into the URL?

Thanks in advance!

Let’s say you have a variable that contains the text, you can just replace spaces with dashes.

[[Variable.replace(’ ‘,’-’)]]

1 Like

Yes! That’s great, silly of me not to have found that myself, but thanks so much for your help, it’s all working perfectly now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.