![]() You can see that the NGINX configuration is quite short and simple. The tester handles regexes in two contexts – map context. ![]() There are numerous websites that provide tools or documentation for building regexes. Explaining how to construct regexes is outside the scope of this post, and we regret that we cannot answer further questions in the comments section about how to do so. NGINX uses Perl Compatible Regular Expressions (PCRE), and this post assumes a basic understanding of both NGINX and regular expressions. In addition, it is always good to be able to test a regex with the actual regex engine in the actual environment. With other regex testers you might have to modify the regex or, in the case of a map, infer what value will be set. Also, when using a regex in a map, you specify what value to set based on a match. For example, you don’t have to escape the forward slash (/) in a URI as you do in a standard regex. ![]() There are other free online regex testers that are good for most regexes, but NGINX uses some non‑standard shortcuts optimized for web applications. The tester described here is for regexes in locations and maps. NGINX allows regexes in multiple parts of a configuration, for example locations, maps, rewrites, and server names. ![]() Support for regular expressions is one of the powerful features of NGINX, but regexes can be complex and difficult to get right, especially if you don’t work with them regularly. (The regex tester works just the same for NGINX Open Source and NGINX Plus, and for ease of reading I’ll refer simply to NGINX in this post.) While working on a regular expression (regex) to use with NGINX, I got an idea for a way to easily test a regex from within an actual NGINX configuration. ![]()
0 Comments
Leave a Reply. |