In dynamic sensor basics, we used the example of a State and City using asterisks for both
Greedy matches
However, this is just for readability to show that we expect there to be 2 levels there. Asterisk will match one or more levels so we could have said Climate_Info\US\*\Temp. We often refer to this as the asterisk is "greedy". It wants to match so it will try to match any anything that matches that pattern.
The slashes are not considered when matching so it will even match metrics with fewer levels. So this one is functionally identical to the first example and both will match the same metrics.
This is particularly useful when the data contains varying levels. For example, perhaps some cities are include their county. Using this technique, we do not need to be concerned about whether Temp is the 4th, 5th or 6th level.
Exact matches
What if you only want to match the number of levels exactly? In that case, instead of using asterisk, you can use a regular expression. A regular expression is not greedy and only applies to the level at which it is specified. For example, if you use Climate_Info\US\%<.*>\%<.*>\Temp,
This will only match if there are 2 levels exactly, such as State and City. It would not match if there more or fewer levels in the hierarchy.
If we only specify one regular expression, than it will only match if the hierarchy matches exactly, e.g. City or State but not both. This does match the same metrics as the previous example,
Summary Notes.
If you find that you are getting data you did not expect, mostly likely it is the greedy asterisk causing it. Swap it for a regular expression to see if the results are as expected.
The regular expressions used above is a basic one. The "%< >" indicates that it is a regular expression. The ".*" is basically saying it can match anything. As used in this example, it matches anything with a value at this level.