• Resolved thebourboncowboy

    (@thebourboncowboy)


    I’ve used regex a lot when I want to skip out on the dates in the url, like this:
    ^/\d{4}/\d{2}/\d{2}/(.*) –> https://newdomain/$1
    but how can I get access to the actual date info?
    I want to go from:
    old.com/2022/09/19/my-new-post to new.com/2022-09-19/my-new-post

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Godley

    (@johnny5)

    You can use the regex to capture the date by putting it in brackets in the same way you are capturing the post name. Then, just like you do with the post name, you insert it into the target. $1 is the first capture, $2 the second, and so on.

    There are many examples of capturing data on regex sites.

    Thread Starter thebourboncowboy

    (@thebourboncowboy)

    Great info. thanks. So I should be able to do something like:
    ^/(\d{4})/(\d{2})/(\d{2})/(.*) –> https://newdomain/$1-$2-$3/$4

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘rearrange dates in url’ is closed to new replies.