Created
April 5, 2024 14:12
-
-
Save gszr/95f78639dc3c4545d199becf9d789d68 to your computer and use it in GitHub Desktop.
ngx.re.gsub options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/openresty/lua-nginx-module?tab=readme-ov-file#ngxrematch | |
``` | |
Specify options to control how the match operation will be performed. The following option characters are supported: | |
a anchored mode (only match from the beginning) | |
d enable the DFA mode (or the longest token match semantics). | |
this requires PCRE 6.0+ or else a Lua exception will be thrown. | |
first introduced in ngx_lua v0.3.1rc30. | |
D enable duplicate named pattern support. This allows named | |
subpattern names to be repeated, returning the captures in | |
an array-like Lua table. for example, | |
local m = ngx.re.match("hello, world", | |
"(?<named>\w+), (?<named>\w+)", | |
"D") | |
-- m["named"] == {"hello", "world"} | |
this option was first introduced in the v0.7.14 release. | |
this option requires at least PCRE 8.12. | |
i case insensitive mode (similar to Perl's /i modifier) | |
j enable PCRE JIT compilation, this requires PCRE 8.21+ which | |
must be built with the --enable-jit option. for optimum performance, | |
this option should always be used together with the 'o' option. | |
first introduced in ngx_lua v0.3.1rc30. | |
J enable the PCRE Javascript compatible mode. this option was | |
first introduced in the v0.7.14 release. this option requires | |
at least PCRE 8.12. | |
m multi-line mode (similar to Perl's /m modifier) | |
o compile-once mode (similar to Perl's /o modifier), | |
to enable the worker-process-level compiled-regex cache | |
s single-line mode (similar to Perl's /s modifier) | |
u UTF-8 mode. this requires PCRE to be built with | |
the --enable-utf8 option or else a Lua exception will be thrown. | |
U similar to "u" but disables PCRE's UTF-8 validity check on | |
the subject string. first introduced in ngx_lua v0.8.1. | |
x extended mode (similar to Perl's /x modifier) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment