regex allowPaths for the template | Community
Skip to main content
bhoang
New Participant
September 20, 2018
Solved

regex allowPaths for the template

  • September 20, 2018
  • 7 replies
  • 1977 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

String length or range you can specify inside {}

example -

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

7 replies

bhoang
bhoangAuthor
New Participant
September 26, 2018

It worked for me.

Thank you so much!

arunpatidar
New Participant
September 21, 2018

Hi,

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

Arun Patidar
bhoang
bhoangAuthor
New Participant
September 21, 2018

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

arunpatidar
New Participant
September 21, 2018
Arun Patidar
bhoang
bhoangAuthor
New Participant
September 21, 2018

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

smacdonald2008
New Participant
September 20, 2018

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

arunpatidar
arunpatidarAccepted solution
New Participant
September 20, 2018

Hi,

String length or range you can specify inside {}

example -

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

Arun Patidar