Expand my Community achievements bar.

SOLVED

regex allowPaths for the template

Avatar

Level 4

Hi Friends,

I want to regex for the template appear in some path. Example: I want the Article template will appear in the path as below when i create page.

 

content/hlo/en/peppa/xx/yyyy

 

xx is country code with two letter

yyyy is the city name (not limited letter)

 

Example some right path:

content/hlo/en/peppa/us/newyork

content/hlo/en/peppa/uk/london

content/hlo/en/peppa/vn/hanoi

 

I was tried this regex "/content/abc/zh/properties/us(/[^/]+){1,1}$" but I want the us is dynamic. So I tried "/content/abc/en/properties/([A-Z][A-Z])(/[^/]+){1,1}$" it doesn't work.

 

/content/abc/en/properties/([A-Z][A-Z])(/[^/]+){1,1}$

 

In this regex [A-Z][A-Z] for two letter ex: us , uk, vn

 

Please help me how to regex it.

Thank you so much,

BienHV

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

String length or range you can specify inside {}

example -

/content/hlo/en/peppa/[a-zA-Z]{2}/[a-zA-Z]{1,}



Arun Patidar

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

Hi,

String length or range you can specify inside {}

example -

/content/hlo/en/peppa/[a-zA-Z]{2}/[a-zA-Z]{1,}



Arun Patidar

Avatar

Level 10

Also - what AEM version are you using? Looks like you are working in Static templates.

Avatar

Level 4

Thank you for your help,

I used this code /content/hlo/en/peppa/([a-z][a-z])(/[^/]+){0,0}$ it work. However, I want to set a condition if the path as /content/hlo/en/peppa/sg the template will not appear.

How to do that?

I am using AEM 6.2

Thank you so much,

BienHV

Avatar

Level 4

Thank you for your help.

I tried but it doesn't work. I want the template accept the path /content/hlo/en/peppa/([a-z][a-z])(/[^/]+){0,0}$

Example: accept any path with type content/hlo/en/peppa/xx with xx is a letter a-z

content/hlo/en/peppa/us

content/hlo/en/peppa/uk

content/hlo/en/peppa/vn

and not accept the path:

content/hlo/en/peppa/sg

Avatar

Community Advisor

Hi,

try /content/hlo/en/peppa/(?!sg)([a-z][a-z])(/[^/]+){0,0}$



Arun Patidar

Avatar

Level 4

It worked for me.

Thank you so much!