2

I created Azure CDN with an endpoint under the Verizon Premium subscription. Then I've logged to the Azure Verizon platform to add a new rule to the engine. If there is no extension at the end of URL, then the .html is added automatically. In the Azure Verizon it looks like this: enter image description here However, if you replace the .+\/[^\.]\w+$ with ^.*/[^/.]+$ it won't work the same don't know why and no validation errors appear. After I read this article my suspicious is there is something to do with the regular expression flavor but I am not sure at all.

GoldenAge
  • 2,918
  • 5
  • 25
  • 63

1 Answers1

3

When you are not sure of the regex engine used, try to only use the most common regex constructs, like ., *, [...]. So, instead of \w, try [a-zA-Z0-9_].

Do not escape anything inside [...], mind that to do that you need to put ] right after the initial [ (not in ECMAScript flavor, you will have to escape ] inside a character class there), - can be put at the end of the character class unescaped, ^ should not be at the beginning. Note that \ can be escaped only in NFA regexps, in POSIX based ones, inside bracket expressions, \ is parsed as a literal \ char as POSIX bracket expressions do not support regex escapes inside them. It makes no sense to escape a . inside [...], the [\.] is an invalid pattern in JS ES6 regex when compiled with u modifier. So, it is safer to write [^.].

Regex delimiters are only used in some programming languages to define regexps, but in software like this you only deal with string patterns. Thus, / is not any special and does not have to be escaped.

So, I'd use the following regex here:

.+/[^.][0-9a-zA-Z_]+$
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • 1
    I received this message from Verizon support "Regex is very flexiable expression. So you can come up with multiple ways to achieve the same desired result. Verizon platform is not tailored towards a specific flavor of Regex, as long as the Regex is in proper syntax, it should work." I think your answer makes perfect sense, so im gonna to accept it. Thanks – GoldenAge Dec 18 '18 at 09:15