Saif Bechan
Saif Bechan

Reputation: 17121

Find all the links in the database that do not have a trailing slash

There are some links in my database that do not have a trailing slash, and for consistency sake, I want all links to have one.

All the links are in this form href="http://mysite.com/page/item/"

Now there are some links that look like this href="http://mysite.com/page/item" and href="http://mysite.com/page/item".

Now I can not find out on what page they are, but they are somewhere in the db, can I use phpmyadmin and regex to find them?

If so, can anyone help me with setting up the regex code, I still can not wrap my head around regex.

Upvotes: 1

Views: 549

Answers (1)

kennytm
kennytm

Reputation: 523484

You should be able to find all entries with the REGEXP operation, e.g.

SELECT * FROM the_table WHERE href REGEXP '[^/]$'

or

SELECT * FROM the_table WHERE href NOT REGEXP '/$'

[^/]: Match any character which is not a slash; $: Match end of string.

Upvotes: 1

Related Questions