Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.
SOLVED

Package Manager filter regex rules?

Avatar

Level 4

I have a project where we have several country websites (20 countries). I'd like to create a package in Package Manager that only grabs each country homepage and not the underlying content. So, for example, homepage content would be located under /content/project/en_us/global/aus/jcr:content

 

Here's the content setup:

/content/project/en_us/global/aus
...more content and directories under aus...
/content/project/en_us/global/aut
...more content and directories under aut...
/content/project/en_us/global/bel
...more content and directories under bel...
 
I've tried these two filter rulesets in Package Manager and none seem to work:

/content/project/en_us/global
exclude: .*
include: .*/[a-z][a-z][a-z]/jcr:content
 
/content/project/en_us/global
exclude: .*
include: /content/project/en_us/global/[a-z][a-z][a-z]/jcr:content
 
Is there a way to regex this? I'd prefer not having to update every time we add another country. Thanks in advance!
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee

Hello @Gunars_V 

Below filter rule should work :

<filter root="/content/project/en_us/global">
<include pattern="/content/project/en_us/global/[^/]+$"/>
<include pattern="/content/project/en_us/global/[^/]+/jcr:content$"/>
</filter>

 

References :
[1] https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/dev...

[2] https://jackrabbit.apache.org/filevault/filter.html#usage-for-export

View solution in original post

3 Replies

Avatar

Employee

Hi @Gunars_V 

In AEM Package Manager, the include and exclude rules are evaluated hierarchically - meaning that when you exclude: .*, you’ve already told the packager to skip everything under that root path, and include won’t override that later down the subtree.

Additionally, the regex syntax in package filters is path-based, not full regex across all levels. It’s best to think of filters as filters on paths rather than file name matches.

Correct Approach:

Since you only want to include jcr:content under each country folder (three-letter folder name), you can do this:

<filter root="/content/project/en_us/global">
<include pattern="/content/project/en_us/global/[a-z]{3}/jcr:content"/>
<include pattern="/content/project/en_us/global/[a-z]{3}$"/>
</filter>

  • You don’t need the explicit exclude: .*.
  • pattern uses regex matching on the full path (not limited by sublevels when using <include>).
  • The $ ensures that the match stops at each country folder, not deeper paths.
  • This will grab:
    /content/project/en_us/global/aus
    /content/project/en_us/global/aus/jcr:content
    /content/project/en_us/global/aut
    /content/project/en_us/global/aut/jcr:content
    ...

But it won’t include descendants like /content/project/en_us/global/aus/offers/....

Avatar

Employee Advisor

Hello @Gunars_V ,

 

Use this filter configuration:

-> Root: /content/project/en_us/global

-> Rules: exclude: .*
include: ^/content/project/en_us/global/[a-z]{3}/jcr:content$

-> Reason:
The regex in Package Manager must match the complete JCR path. By excluding everything first, only the paths defined in the include rule are added. This include pattern captures only the homepage jcr:content nodes for each three-letter country folder, so it works automatically for all countries.

If country code length is different, use this instead:
include: ^/content/project/en_us/global/[^/]+/jcr:content$

 
 

Avatar

Correct answer by
Employee

Hello @Gunars_V 

Below filter rule should work :

<filter root="/content/project/en_us/global">
<include pattern="/content/project/en_us/global/[^/]+$"/>
<include pattern="/content/project/en_us/global/[^/]+/jcr:content$"/>
</filter>

 

References :
[1] https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/dev...

[2] https://jackrabbit.apache.org/filevault/filter.html#usage-for-export