JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = 'abcde abcde'; 
var re = /(?:ab)(cde)/g;
str.replace(re, function(str, cde){
  alert(cde);
});