JSFiddle - React, Tailwind, and code Playground

by Hans PUFAL

HTML

<pre id="results"></pre>

JavaScript

function removeProperties (obj, prop) {
  Object.keys (obj).forEach (
    function (p) {
      if (typeof prop === 'string' ? p.indexOf (prop) == 0 : prop.test (p)) 
        delete obj[p]; 
  });
  return obj;
}

document.getElementById ('results').innerHTML = 'Results : \n  ' + 
  [ [{"MainASubB":"AB","MainBSubC":"BC"}, 'MainA'],
    [{"MainASubB":"AB","MainBSubC":"BC"}, /^MainA/],
    [{"MainASubB":"AB","MainBSubC":"BC"}, 'Main']
  ].map (function (t) { return JSON.stringify (removeProperties.apply (null, t)); }).join (', \n  ');