JSFiddle - React, Tailwind, and code Playground

by gmcalab

JavaScript

let x = "You lost s:{1,Hitpoints} due to getting splattered with i:{Offense.FlamingPoop}!"

let y = "Stuff in here";

//const regex = new RegExp("(s:\{[0-9a-zA-Z,]+\})", 'g');
const regex = new RegExp(/([si]:\{[\w,.]+\})/);
//const regex = new RegExp(/(i:\{[\w.]+\})/g, 'g');
const match = y.split(/([si]:\{[\w,.]+\})/g);
console.log('start')

if (match !== null) {

      match.forEach((m) => {
         console.log(m);
      });
   }
else
console.log('null')