DataTree rule notation


I am trying to replace data tree paths but I’m having trouble understanding the difference between rule notations {*} and {?}.I have read which explains that:

* Any number of integers in a path
? Any single integer

The asterisk achieves what I’m trying to do, but I would still like to know how they are different exactly. I have attached a screen capture for reference. Thanks.

The asterisk represents any number of integers, including zero. The question mark represents any single integer. So assuming a path which looks like {0;1;2}, you’ll get a match with {?;?;?} and with {?;?;2} but not with {?;?}.

When using asterisks, you have a lot more flexibility. {*} will match any imaginable path. {*;2} will match any path ending in 2. {*;2;*} will match any path containing 2, even if it only starts or ends with a 2.

1 Like

Ahhhh it makes sense now. Thank you.