Skip to main content
Best answer

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

  • May 7, 2024
  • 5 replies
  • 104 views

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.

5 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34020 replies
  • May 7, 2024

Hi @MatthewS 

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

Formatter > Text > Lowercase

Formatter > Text > Replace

Formatter > Text > Extract Pattern


  • Author
  • Beginner
  • 2 replies
  • May 7, 2024

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


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34020 replies
  • May 7, 2024

@MatthewS 

Yes, that’s the idea.


  • Author
  • Beginner
  • 2 replies
  • May 7, 2024

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? 


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34020 replies
  • Answer
  • May 7, 2024

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