Jump to content

Text to url slug with regex


nagif
 Share

Recommended Posts

Hello,

I am trying to create a slug from a text value. Take for example a blog post titled: This is My Blog Title!!!

The slug should be something like this-is-my-blog-title

Space and punctuation are stripped out.

I’m trying to use regex to make this happen. Here is where I got so far.

First I’m making the entire string lowercase
Find and replace! with null space
Find and replace with regex expression [^0-9a-zA-Z]+
The issue I’m running into is that I still end up with the “-” at the end of the slug.

Does anyone have experience with this sort of issue?

Link to comment
Share on other sites

Just now, nagif said:

Hello,

I am trying to create a slug from a text value. Take for example a blog post titled: This is My Blog Title!!!

The slug should be something like this-is-my-blog-title

Space and punctuation are stripped out.

I’m trying to use regex to make this happen. Here is where I got so far.

First I’m making the entire string lowercase
Find and replace! with null space
Find and replace with regex expression [^0-9a-zA-Z]+
The issue I’m running into is that I still end up with the “-” at the end of the slug.

Does anyone have experience with this sort of issue with Conert Text into slug by spytools?

thanks for any hep

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share



×
×
  • Create New...