I tried to use a regular expression to generate a value for a custom dimension from the URL.
Here I read that I should use a Regular Expression testing tool like https://regex101.com/ to prevent mistakes.
But my impression is that, for example, escaping an URL slash in Matomo is wrong and I have to do without backslashes instead.
URL: /de/area1/xyz.html or /de/area2/xyz.html
To extract area1 or area2 I have following regex:
Correct Regex: \/de\/([a-zA-ZäöüÄÖÜ-_]+)
Matomo regex that delivers the desired results: /de/([a-zA-ZäöüÄÖÜ-_]+)
Is the documentation with the reference to regex101.com not precise enough or is the regular expression implementation in Matomo different?
Thank you for creating the issue @utrautmann Likely this needs to be mentioned in the FAQ and is expected behaviour.
This is kind of documented in https://matomo.org/faq/how-to/custom-dimensions-extractions/
Developers Note: You don’t need to escape forward slashes as Matomo does this for you automatically. e.g. use /news/ instead of \/news\/
One easy solution in regex101 is to set the delimiter left of the regex to something else than / (this way one doesn't need to escape it there just like in Matomo)
We only need to mention this in the inline help of the related form field that slashes don't need to be escaped