I have an array of Objects that I am trying to group based on the title regex value.
Example array:
[
  {
    id: "1",
    title: "[GroupA] Example Title",
    date: "example date",
  },
  {
    id: "2",
    title: "[GroupA] Example Title",
    date: "example date",
  },
  {
    id: "3",
    title: "[GroupB] Example Title",
    date: "example date",
  },
  {
    id: "4",
    title: "[GroupC] Example Title",
    date: "example date",
  },
];
I am trying to group each object based on the title: "[Group]"
The following .replace() gives me the Group value
let titleValue = data.title.replace(/(^.*\[|\].*$)/g, "");
// result: GroupA, GroupA, GroupB, GroupC
How would I be able to group these object arrays under their titleValue
TIA
 
    