Below is an array that I have:
var Array = [{id:100,name:'N1',state:'delhi',country:'india',status:'active'},
{id:101,name:'N2',state:'kenya',country:'africa',status:'suspended'}
{id:102,name:'N3',state:'kerala',country:'india',status:'inactive'}
{id:103,name:'N4',state:'victoria',country:'australia',status:'active'}]
I also have a search field where I need to filter the array based on the searched value and return the matching object. The challenge I face is that I do not know in advance what key-value pairs will be present in the array as they are dynamically generated. Additionally, I am looking for suggestions on how to utilize Regex to search the array. It should match each character I type and return the matching object in an array. An example of the expected result is shown below:
search key : ind
[{id:100,name:'N1',state:'delhi',country:'india',status:'active'},
{id:102,name:'N3',state:'kerala',country:'india',status:'inactive'}]
search key : N2
[{id:101,name:'N2',state:'kenya',country:'africa',status:'suspended'}]
Any advice or suggestions would be greatly appreciated. Thank you.