Best answer

How do I convert YouTube titles (text & numbers only) to Webflow slugs using Zapier?


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? 

icon

Best answer by Troy Tessalone 7 May 2024, 17:56

View original

5 replies

Userlevel 7
Badge +14

Hi @MatthewS 

Try using the Formatter app: https://zapier.com/apps/formatter/help

Formatter > Text > Lowercase

Formatter > Text > Replace

Formatter > Text > Extract Pattern

Ok understood. So lowercase. Then replace [:space] into “-”. Then extract the text, numbers and “-” to get a final result? 

Userlevel 7
Badge +14

@MatthewS 

Yes, that’s the idea.

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? 

Userlevel 7
Badge +14

@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}];

 

 

 

Reply