I want to know if is possible get the unmatched result from a Regexp and put this values in array (just an inversing match).
This code handle the solution partially with replace:
str = 'Lorem ipsum dolor is amet <a id="2" css="sanitizer" href="#modal-collection" data-toggle="modal" data-target="#ae" data-toggle="modal" data-attr-custom="test">Lorem ipsum </a> the end';
let elementRegexp: RegExp = new RegExp('<([^>]+?)([^>]*?)>(.*?)>','g');
let text = str.replace(elementRegexp, '');
let matchElements = str.match(elementRegexp);
console.log(text);
//Lorem ipsum dolor is amet the end
console.log(text);
//["<a id="2" css="sanitizer" href="#modal-collection"…="modal" data-attr-custom="test">Lorem ipsum </a>"]
Expected result:
["Lorem ipsum dolor is amet", "the end"]