How To Use Wildcards In The Path
<< Back to the .Networking page
You can use wildcard characters when using Shared Dictionary paths:
The * wildcard matches zero or more characters traversing sub-trees.
For example, /countries/*/capital
would match /countries/Canada/capital
and /countries/USA/capital
.
The ? wildcard is similar, but scans only one level in the hierarchy.
For example, /countries/?/population
would match /countries/Canada/population
but not /countries/USA/California/population
.
The + wildcard matches a sub-tree and its root.
For example, /countries/Canada+
matches /countries/Canada
and any keys under it, like /countries/Canada/anthem
, /countries/Canada/Alberta/capital
.
The & wildcard matches a GUID (Globally Unique Identifier) string.
For example, /countries/&
matches /countries/{1a743fe3-5a5f-ed43-c32b-345ea8fb3c5a}
.
The ^ wildcard matches a string of consecutive numbers.
For example, /countries/Canada^
matches /countries/Canada1
and /countries/Canada123
, but not /countries/Canadas
.
Exercise 1
Cover the righthand column and see if you can guess which keys match which subscription patterns.
No Wildcard
Subscription | Key | Match |
---|---|---|
/note | /note2 | No |
/note | /note2/text | No |
/note | /note | Yes |
/note | /note/text | No |
* Wildcard
Subscription | Key | Match |
---|---|---|
/* | /note | Yes |
/* | /note/text | Yes |
/* | /note2 | Yes |
/note/* | /note/text | Yes |
/note/* | /note/text/font | Yes |
/note/* | /note2 | No |
/note/*/font | /note/text/font | Yes |
/note/*/font | /note/caption/text/font | Yes |
/note/*/font | /note/font | No |
/note/*font | /note/text/font | Yes |
/note/*font | /note/caption/text/font | Yes |
/note/*font | /note/font | Yes |
/note/*font | /note/titlefont | Yes |
/note*font | /note/font | Yes |
/note*font | /notefont | Yes |
/note* | /note | Yes |
/note* | /note2 | Yes |
/note* | /note2/text | Yes |
? Wildcard
Subscription | Key | Match |
---|---|---|
/? | /note | Yes |
/? | /note/text | No |
/note/? | /note/text | Yes |
/note/? | /note | No |
/note?/text | /note2/text | Yes |
/note?/text | /note2/caption/text | No |
/note?/text | /note/text | No |
+ Wildcard
Subscription | Key | Match |
---|---|---|
/+ | /note | Yes |
/+ | /note/text | Yes |
/+ | /note2 | Yes |
/note+ | /note | Yes |
/note+ | /note2 | No |
/note+ | /note2/text | Yes |
/note+/text | /note2/text | ERROR! |
& Wildcard
Subscription | Key | Match |
---|---|---|
/note/&/text | /note/caption/text | No |
/note/&/text | /note/{1a743fe3-5a5f-ed43-c32b-345ea8fb3c5a}/text | Yes |
/note&/text | /note{1a743fe3-5a5f-ed43-c32b-345ea8fb3c5a}/text | Yes |
^ Wildcard
Subscription | Key | Match |
---|---|---|
/note^ | /note1 | Yes |
/note^ | /note11 | Yes |
/note^ | /notes | No |
/note^/text | /note1/text | Yes |