Question: So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records...

```
db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ])

```

I need to modify this line to display only the records with a city who has a name that is a number (2,3,4, etc)....I think I can use '$match', but how?

```
db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}}, {$match:{???what_to_say_here???} ]) 

```

How to say 'match when city is a number'?

the out put I get looks like this...

```
    {
        "city" : "A",
        "_id" : "04465"
    },
    {
        "city" : "1",
        "_id" : "02821"
    },
    {
        "city" : "0",
        "_id" : "04689"
    }

```

I'm trying to display only the records with a numeric string...this is related to a larger "homework" problem but I can't even get to the actual homework question until I get past this point.

Answer: 
You can also use an `in` command

```
db.zips.aggregate([     
    {
        $project: {
            first_char: { 
                $substr : ["$city",0,1]
            }, 
            "_id":"$_id"
        } 
    }, 
    {
        $match: {
            first_char: { 
                $in: ["0","1","2","3","4","5","6","7","8","9"] 
            }
        }
    }
]) 

```
With the mongodb **4.4** (upcoming), You can use [**`$isNumber`**](https://docs.mongodb.com/master/reference/operator/aggregation/isNumber/) pipeline operator to check whether the expression is integer or other BSON type.

```
db.zips.find({ "$expr": { "$anyElementTrue": { "$isNumber": "$city" }}})

```

[**`$isNumber`**](https://docs.mongodb.com/master/reference/operator/aggregation/isNumber/) will return true or false corrsoponding to the expression and [**`$anyElementTrue`**](https://docs.mongodb.com/master/reference/operator/aggregation/anyElementTrue/) will return the `$match`ed documents.