Here is the issue:
I go this Code:
var str = {"Acc":10 , "adm_data":"Denied"};
When I do something like:
console.log(str.Acc.match(/[0-9]+/g)) // To Get the Integer Value from the "Acc" key
Firebug Screams:
TypeError: str.Acc.match is not a function
console.log(str.Acc.match(/[0-9]+/g));
See Image:
I always do something like:
var str = "Hello _10";
console.log(str.match(/[0-9]+/g)) // This Works
Why is the Object
thingi not working?
PLEASE NOTE:
As mentioned by
@Fabrício Matté.
The issue was that I was trying to pass aninteger
Value to the.match
method which does not belong tointegers
. The solution was to do what@kundan Karn
Suggested. Something like:str.Acc.toString().match(/[0-9]+/g)// Converting it first to string then match
. It worked!