Convert an object into an array of objects base on a substring in the keys

I have an object that looks like this:

const object = {
User 1 Fecha de Nacimiento: "02/05/2000",
User 1 Porcentage: 25,
User 1 Primer Apellido: "Gonzalez",
User 1 Segundo Apellido: "Perez",
User 1 Sexo: "H",
User 1 nombre: "Manuel",
User 2 Fecha de Nacimiento: "02/05/2000",
User 2 Porcentage: 25,
User 2 Primer Apellido: "Diaz",
User 2 Segundo Apellido: "Rodriguez",
User 2 Sexo: "M",
User 2 nombre: "Pepa",
}

I would like to manipulate this object so it gets transform in an array that looks like this base on the information for each user (ie, 1 or 2):

const arrayOfObjects = [
                        {
                         Fecha de Nacimiento: "02/05/2000",
                         Porcentage: 25,
                         Primer Apellido: "Gonzalez",
                         Segundo Apellido: "Perez",
                         Sexo: "H",
                         Nombre: "Manuel"
                        }, 
                        {
                         Fecha de Nacimiento: "02/05/2000",
                         Porcentage: 25,
                         Primer Apellido: "Diaz",
                         Segundo Apellido: "Rodriguez",
                         Sexo: "M",
                         Nombre: "Pepa" 
                        }
                       ]; 

I will need to have a helper funcion to do it, so I can then store it in a react state (funcional component)

Answer

const srcObject = {
  "User 1 Fecha de Nacimiento": "02/05/2000",
  "User 1 Porcentage": 25,
  "User 1 Primer Apellido": "Gonzalez",
  "User 1 Segundo Apellido": "Perez",
  "User 1 Sexo": "H",
  "User 1 nombre": "Manuel",
  "User 2 Fecha de Nacimiento": "02/05/2000",
  "User 2 Porcentage": 25,
  "User 2 Primer Apellido": "Diaz",
  "User 2 Segundo Apellido": "Rodriguez",
  "User 2 Sexo": "M",
  "User 2 nombre": "Pepa",
}


const transformData = (src) => {
  const results = [];
  Object.keys(src).forEach(key => {
    const split = key.split(/^User (d+) /).filter(i => i !== '')
    const index = +split[0] - 1
    const newKey = split[1]
    if (!results[+index]) {
      results[+index] = {}
    }
    results[+index][newKey] = src[key]
  })
  return results
}




console.log(transformData(srcObject))