I am trying to figure out the best way to approach this issue. I need a “slug” or a formatted text that works in URLs in Webflow. For example “this-is-a-slug”:
https://website . com/this-is-a-slug
I have text such as “The New Age of AI is here!” which is a title from Youtube and I need to remove everything except text and numbers and change spaces into a slug “the-new-age-of-ai-is-here” to add a new page to my Webflow.
Is this possible with Zapier?
Best answer by Troy Tessalone
@MatthewS
Try this Code (JavaScript) to replace all the Formatter steps.
let X = clean(inputData.X);
function clean(inputString) { // Remove non-alphanumeric characters except spaces let cleanedString = inputString.replace(/[^a-zA-Z0-9\s]/g, '');
// Lowercase the string cleanedString = cleanedString.toLowerCase();
// Replace spaces with - cleanedString = cleanedString.replace(/\s+/g, '-');
return cleanedString; }
output = [{X}];
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.
Last question. I just tried the extract function, but its just giving me an array of results. For example, using [a-b0-9-] to extract the result gives me an array of each letter an number matched. Thats not very useful. I tried to play with the other settings without success. Am I missing something in the regex?