Title: Remove Categories with Regular Expression (regex)
Last modified: October 14, 2020

---

# Remove Categories with Regular Expression (regex)

 *  Resolved [freemason](https://wordpress.org/support/users/freemason/)
 * (@freemason)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-categories-with-regular-expression-regex/)
 * Hi,
 * I need to change my website permalinks from domain/category/postname to domain/
   postname.
 * I’ve been trying to write a Regular Expression (regex) to do this, but my knowlowdge
   is very low and couldnt succeed until now.
 * Can anybody help me on this?
 * Thanks in advance for your kind help.
 * Regards
    A Jorge

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-categories-with-regular-expression-regex/#post-13536758)
 * What regular expression have you created? Have you tested it with [https://regex101.com](https://regex101.com)?
 *  Thread Starter [freemason](https://wordpress.org/support/users/freemason/)
 * (@freemason)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-categories-with-regular-expression-regex/#post-13538846)
 * Hi John,
 * Based on the regex you present in your website that removes date, name, and category
   in a permalink ^/\d{4}/\d{2}/\d{2}/.*?/(.*), I have been struggling with ^/.*?/(.*)
   to try to remove category and subcategory (if exists) from domain/category/subcategory(
   if exists)/postname.
 * I tryed with [https://regex101.com](https://regex101.com), but couldnt find the
   solution. Can you please help on this?
 * Regards
    Antonio Jorge
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/remove-categories-with-regular-expression-regex/#post-13539435)
 * That pattern works in regex101 when I test it:
 * [https://regex101.com/r/LsWtR5/1](https://regex101.com/r/LsWtR5/1)
 * You may need to clear your browser cache, or any caching system you have installed.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Remove Categories with Regular Expression (regex)’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

## Tags

 * [regex](https://wordpress.org/support/topic-tag/regex/)

 * 3 replies
 * 2 participants
 * Last reply from: [John Godley](https://wordpress.org/support/users/johnny5/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/remove-categories-with-regular-expression-regex/#post-13539435)
 * Status: resolved