My first regex, need opinions
-
Hello, i made my first regex. I read the documentation and googled a bit and came up with one. It works. But i wanna know the opinion of someone with regex knowledge.
What it does is redirects paginated archives to parent. that is:
/page/2/
from the homepage or from custom types archives.
It also “saves” the custom post type slug (if present) and eventual query parameters (if present).This is the regex, source:
\/([^\/^.]*)\/?page\/[0-9]{1,3}\/(.*)
TARGET URL
/$1/$2
TEST URLS:
/page/2/ /custom-type/page/40/ /custom-type/page/999/?language=english&filter_genre=action
Please tell me what you think if there’s something obviously wrong, thanks.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘My first regex, need opinions’ is closed to new replies.