RegexReplace query

Kurt Muller asked on September 26, 2019 14:22

Hi there

I'm building a Portuguese website where the URLs are built up from the page name. The problem is that Kentico replaces all special characters with basic regex characters. The problem is that I am trying to build up the page url with macros but am looking for a way to do a Regex Replace using a full expression.

I am aware I can do single character replacement with RegexReplace("ã", "a"), but I want to be able to replace multiple characters and not just one at a time.

Any change of this?

First prize would be for Kentico to accept special characters in my page alias ;)

Recent Answers


David te Kloese answered on September 26, 2019 14:39 (last edited on September 26, 2019 15:03)

I'm not sure if Diacritics are allowed nowadays... but they didn't used to from SEO perspective as some browsers will encode "é ñ" to é ñ

..

You could also implement a custom handler to transform special characters to something readable: https://www.kentico.com/blog/transforming-urls-with-kentico-ems

like '&' to 'and'

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on September 26, 2019 15:02

Well adding it to allowed character doesn't work, so scratch that.

And for the handler you are probably already at that point. I suggest taking this to code and use .NET's String.Normalize as mentioned here: stackoverflow.com/.../how-do-i-remove-diacritics-accents...

In case you really need it to be done in a macro you could create your own custom macro to handle it: docs.kentico.com/.../registering-custom-macro-methods

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.