How to extract the only number from string which starts with number in MongoDB
I want to extract the number from a string which starts with the number.
I have a collection which contains document like
{
"address" :"1103 wood crest"
},
{
"address": "223 NW 28TH ST"
},
{
"address": "NW 28TH ST"
},
{
"address": "28TH ST ava"
}
I want to write aggregation query, which gives result in below format: below:
{
"number": "1103",
"address" :"wood crest"
},
{
"number": "223",
"address": "223 NW 28TH ST"
},
{
"number": "",
"address": "NW 28TH ST"
},
{
"number": "",
"address": "28TH ST ava"
}