I have a json array:
var arr =
[
{
"path": "a/b/c/*",
"id": "1"
},
{
"path": "l/m/*/n",
"id": "2"
},
{
"path": "a/b/c/d/*",
"id": "3"
}
]
I want the id of the element which matches the input param, like if I pass a input string and the array I should get the id
foo(input,arr);
so
var input = 'a/b/c/5'; //or input = 'a/b/c/4';
foo(input,arr) // should return 1
similarly
var input = 'l/m/78/n';
foo(input,arr); // should return 2
similarly
var input = 'a/b/c/d/1';
foo(input,arr); // should return 3
So I want * to be the wildcard while search. I have struggled a lot while implementing this, any help will be appreciated.