Gearset's customizable filters let you control the types of metadata that are displayed in your comparison results. To add an additional layer of granularity, you can use regex filtering to include or exclude specific named items. For more information on how to create or edit a custom metadata filter, see this article.

You can use regex filtering to either include or exclude items from your comparison results. In this article we'll demonstrate how to use this powerful feature to tune your custom filters.

Switching to named items

First, find the metadata type you're after from the left-hand list, and switch the toggle to Named items.

You should note that when you switch to Named items, no items are included by default. You can select specific items to include in your filter and subsequent comparison either by using the checkboxes or by adding regex. 

Including items based on regex

Imagine you want to include all items that begin with Site. Rather than selecting every item manually, you can add a regex rule to include all matching items. Select Regular expression from the left-hand dropdown and type the regex pattern ^Site.* into the text field. Click Add to save the rule.

Excluding items based on regex

Sets of items can be excluded by a regex pattern in much the same way as they are included above, by selecting the Exclude option on the right-hand dropdown when Regular expression is selected on the left.

The key difference with exclude regex is that items that match the pattern are excluded no matter what, regardless of whether they were included individually or via regex pattern. Exclude regex takes priority over any other filters.

Consider the below example:

The include regex will find Task, Topic and TopicAssignment, in addition to the explicitly included Solution, StreamActivityAccess and User.  However, the exclude regex will match Topic, TopicAssignment and StreamActivityAccess.

As a result, the final set of objects to be included in the comparison will be Task, User and Solution only.

Building a complex filter with includes and excludes

Include and exclude filters can be layered to create complex metadata filters. 

Take the first example in this doc, including Site items. Imagine you want to exclude SitePoweredBy from the comparison, but include all other Apex components. 

Select Object name from the left dropdown, type the name of the item you want to exclude, and switch the right dropdown to Exclude. Hit Add to save the rule.

If you left things there, SitePoweredBy would be excluded, but so would every other Apex component! Now you would need to add the include regex term .* which includes all other items of this metadata type.

Using these filters you can build up complex metadata filters to fine tune your comparisons and control exactly which items you want to compare and deploy.

However do note that the regex rule only apply to the top level named item, and not to subcomponents. For example, the regex will only apply on the Custom object and not on List views or Custom field.

Want to know more about regex? The Mozilla developer site has a great introduction to regex rules to get you started. You can visit it here:

Did this answer your question?