Encoded String Parse

Published by Deep Xavier in

Create a function which takes in an encoded string and returns an object according to the following example:

Examples

parseCode("Tesha000Deep00014344") ➞ {
  "firstName"="Tesha",
  "lastName"="Deep",
  "id"="14344"
}

parseCode("John000Doe000123") ➞ {
  "firstName"="John",
  "lastName"="Doe",
  "id"="123"
}

parseCode("kevin0smith004331") ➞ {
  "firstName"="kevin",
  "lastName"="smith",
  "id"="4331"
}

parseCode("Thomas00LEE0000043") ➞ {
  "firstName"="Thomas",
  "lastName"="LEE",
  "id"="43"
}

parseCode("Madsy0Jupiter0321") ➞ {
  "firstName"="Madsy",
  "lastName"="Jupiter",
  "id"="321"
}

Notes

  • The string will always be in the same format, first name, last name and id with zeros between them.
  • id numbers will not contain any zeros.
  • Bonus: Try solving this without RegEx.
Watch a quick demo on how Edabit works.