Regex for slug without using plugin

Hello friends how are you?
Can anyone give me a regex to turn titles into a slug?
I currently have a system that if my user changes the company name, I need to change the Slug of several pages, when this happens my server is at maximum capacity because I use a plugin that does it for me, in this case I would like a way to not overload the server and also streamline this process because it is very slow even using backend workflow.
I currently use the Normalize plugin, but I’ve used others and have the same result

ChatGPT does a great job of proving Regex.

1 Like

I’ll look for it, but at the moment, I can’t access it.

I’ve used this Stack Overflow thread as guidance for something similar.

I’m curious in the cascade of events that happens after a user changes the company’s slug. Maybe there are some efficiencies there.

1 Like

image

[\W_]+

1 Like

This expression is still not correct, but it helped a lot.
The problem is, my precision pages have slugs based on:
company_name - page_title".
Example:
hotel-new-york(company name)-room-service(page name).
and in cases of accents and other characters, he is replacing everything with “-” for example “déjá vu” would be “d-j-” and the ideal would be “deja”

Then do a find and replace for characters with accents?

You can do multiples at once on the same end character.

image

etc

1 Like

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