Workers Redirect URL using regex

Hey, i need to redirect a regex* to$1. This setting will easily work with a pagerule. But how do i do it with cloudflare workers?

async function handleRequest(request) {
return Response.redirect(someURLToRedirectTo, code)
addEventListener(‘fetch’, async event => {
const someURLToRedirectTo = ‘$1’ //this is wrong…
const code = 302

I don’t know coding. Help me with this.