'Mongo regular expression no more then one dot in field

I need to select all records which contain no more than one dot in the field name.

For example:

A.* - include to select B.* - include to select

A.C.* - exclude (2 dots) A.C.D.* - exclude (3 dots)

All filtered strings always end with .* but I need select only records with one single dot.

@Query(value = """
        {
            "name" : {
                "$regularExpression" : { "pattern" : .*\\.., "options" : ""}
            }
        }
        """)
Flux<Subject> findRoots();


Solution 1:[1]

I know this core mongo Query but might be it's helpful to you.it's Working for me

 db.getCollection('test').find({data:{ "$regex": /^[a-z\d,]*\.?[a-z\d,]*$/ ,  $options :"i"} })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RONAK SUTARIYA