JSFiddle - React, Tailwind, and code Playground

by jfriend00

JavaScript

var str = "#r;\n text1 \n#r;\n#r;  text2 \n#r;";

var matches = str.match(/#r;\s*(.*?)\s*#r;/);
alert('"' + matches[1] + '"');