JSFiddle - React, Tailwind, and code Playground

JavaScript

let s = "gateway/?redirect=[URLENCODE('https://site.co/?payment_plan_id=PAYMENT_PLAN')]";
let res = s.match(/_plan_id=(.*)\'\)/);
console.log(res[1]);