Below is an explanation based on the Eventarc path pattern documentation:
Matching Multiple Collections
According to the documentation, the path pattern syntax for Cloud Eventarc (and thus for triggering Cloud Functions on document changes) does not support union operations for capture groups. In other words, you cannot specify a single capture group that matches either "users" or "clients" by writing something like:
{col=[uc]*s}/{id}
{col=[clients,users]}/{id}
{col=clients,users}/{id}
The syntax only allows you to capture one fixed literal name segment (with an optional wildcard in between characters). Therefore, if you are trying to match documents created in both the users/
and clients/
collections with one trigger, the path pattern language does not provide a way to combine them in the same expression.
CaptureGroup Limitations
A capture group is limited to a single optional expression that is typically a name segment. This means you cannot combine multiple literal segments or add union-like regex capabilities. The allowed structure is closer to a fixed literal with an optional wildcard rather than a full regular expression.
Allowed Characters Clarification
The characters listed (e.g. \w \s \t ~@#$%&.,?:;+='[]()-
) represent the specific literal characters allowed in a name segment. They are not a full regex engine that lets you say “match clients or users.” Instead, they are simply the literal characters that can appear and be matched by the name segment. In short, you cannot construct regex-style union patterns here.
Recommendations
If you need to trigger a Cloud Function for both paths, you have two options:
- Create Separate Triggers: One trigger for the
users/
collection and another for the clients/
collection.
- Use a More General Pattern With Filtering: If possible, use a broader path pattern and add logic in your function to filter out results that don’t belong to the desired collections. (This depends on your use case and may not be as efficient or desirable.)
In summary, the current path pattern syntax does not support matching two collections within one capture group using regex-like or union constructs. Each event filter must precisely match the intended path structure as defined by the documentation.