0

What are the wildcard characters that are allowed for Cloudant regex queries in selectors? For e.g, If want to to retrieve all records that contain a key "name" whose value begins with "S". Can we write it this way:

"selector":{
   "name":{
       "$regex":"S*"
    }
}

Also, if I want to retrieve records having "a" as the second character in name, then can we write,

"selector":{
   "name":{
       "$regex":".a"
    }
}
shA.t
  • 16,580
  • 5
  • 54
  • 111
ShwetaJ
  • 462
  • 1
  • 8
  • 32
  • Possible related: [Reference - What does this regex mean?](https://stackoverflow.com/q/22937618/4519059) ;). – shA.t Oct 08 '17 at 05:17

1 Answers1

0

according to Cloudant $regex query:

The matching algorithms that are used by the $regex operator are currently based on the Perl Compatible Regular Expression (PCRE) library External link icon. However, not all of the PCRE library is implemented. Additionally, some parts of the $regex operator go beyond what PCRE offers. For more information about what is implemented, see the Erlang Regular Expression External link icon information.

and from the Erlang Regular Expression it appears that both the asterisk and dot are implemented:

.   Match any character except newline
*   0 or more quantifiers
shA.t
  • 16,580
  • 5
  • 54
  • 111
vabarbosa
  • 706
  • 1
  • 4
  • 9