Named argument for excluding matches #30
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#30
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This feature request is intended as a stop-gap solution to introduce the feature of excluding matches from wildcards #21 prior to implementing or even deciding on syntax changes. For this proposal,
ExcludeMatchesis considered for the named argument. There are two considered approaches:The first approach is the simpler but less general of the two. The named argument would be take a string vector (or cell-char equivalent) value. Any fields within the mpath expression will exclude any fields that is a member of this set of strings. For example, in
mpath.resolve(S, "/*#2/*#3", ExcludeMatches=["A", "X"]), neither*#2nor*#3could match the fieldAor the fieldX.The second approach is more complex while more general. The named argument would be a dictionary mapping numbers to sets. There are two variants of this. If the numbers are indices, they would represent the occurrence index of
DotGlobwithin the mpath expression. For example, inmpath.resolve(S, "/*#2/*#3", ExcludeMatches=dictionary(1, {"A"}, 2, {"X"}])),*#2could not match the fieldAand*#3could not match the fieldX. If the numbers are dimensions, they would represent the dimension in the result. For example, inmpath.resolve(S, "/*#2/*#3", ExcludeMatches=dictionary(2, {"A"}, 3, {"X"}])),*#2could not match the fieldAand*#3could not match the fieldX. In the later approach, it is possible a single dictionary key-value pair could restrict multiple wildcards since it would be possible for a single dimension to be associated with multiple segments.Both approaches could be implemented as it would be unambiguous which case is being handled based on the datatype. Though of the two variants of the second approach, just one would need to be chosen.
In both approaches, a set of fields will be excluded from being matched, as if it were not a field at all. This means a value for
NullFieldfrom #11 ofmissingorretainwould not be included at all, anderrorwould not give an error for the corresponding fields.