Input:
[
{
"name": "TOOL: 5237"
},
{
"name": "DMP: 213213 RENTAL"
},
{
"name": "SMG: 23434-A"
}
]
This is my Input , I want to only print the numbers/ID's in the name
my Expected output should be
[
"5237"
,
"213213"
,
"23434"
]
It would be helpful you someone gives me the logic to do it. Thank you
This would be one of the few cases to actually use a regular expression. Because the function scan() returns an array of arrays I used flatten() and the indexed selector (
[]) to return the actual matching sub string that will be a sequence of digits. Since there is one and only one sequence of digits in each strings it will return the actual number.Output: