Regex is not Taking Asset path | Community
Skip to main content
Level 3
December 16, 2024

Regex is not Taking Asset path

  • December 16, 2024
  • 1 reply
  • 525 views

Dear All,

 

I have below regex for creating article Content Fragment

 

new RegExp("\\/mnt\\/overlay\\/dam\\/cfm\\/admin\\/content\\/v2\\/createfragment.html\\/content\\/dam\\/content-admin\\/(\\w)+\\/articles\\/[\\w|-]+\\/[\\w|\\s|-]+\\/([\\w\\d]){4}(\\/(\\w)+)?");

 

When we try to create the article CF under the path then it is not taking the bracket as the folder technology-and-activation-group-(taag)

 

http://localhost:4502/assets.html/content/dam/content-admin/global/articles/test/technology-and-activation-group-(taag)/2024/december

 

Can you please help me here how to change the regex so that it will take bracket.

1 reply

abhishekanand_
Community Advisor
Community Advisor
December 16, 2024

Hi @subnaik 

try below regex once will you:
new RegExp("\\/mnt\\/overlay\\/dam\\/cfm\\/admin\\/content\\/v2\\/createfragment.html\\/content\\/dam\\/content-admin\\/(\\w)+\\/articles\\/[\\w|-]+\\/[\\w|\\s|-]+\\/([\\w\\d]){4}(\\/(\\w|\\(|\\))+)?");

By adding \\( and \\) inside the capture group, the regular expression can now match folder names that include both opening ( and closing ) brackets, in addition to word characters (\w).

Hope this helps!

Abhishek Anand
subnaikAuthor
Level 3
December 24, 2024

Hi @abhishekanand_ ,

 

I tried below regex and still it is not working

 

var createArticleUpdatedURLRE = new RegExp("\\/mnt\\/overlay\\/dam\\/cfm\\/admin\\/content\\/v2\\/createfragment.html\\/content\\/dam\\/content-admin\\/(\\w)+\\/articles\\/[\\w|-]+\\/[\\w|\\s|-]+\\/([\\w\\d]){4}(\\/(\\w|\\(|\\))+)?");