You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
change: unmatched captures are set to false in the captures table.
Now unmatched capture groups in `ngx.re.match`, `ngx.re.gmatch`,
`ngx.re.sub`, and `ngx.re.gsub` are
set to `false` rather than nil. This prevents to create tables with
holes that don't play nicely with `ipairs` or `#` operators.
For consistency, unmatched trailing captures (for instance in
`ngx.re.match("hello", "(hello)(.+)?")`) are
also set to `false`.
Named captures are not affected.
Copy file name to clipboardExpand all lines: README.markdown
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -861,7 +861,6 @@ TODO
861
861
* cosocket: pool-based backend concurrency level control: implement automatic `connect` queueing when the backend concurrency exceeds its connection pool limit.
862
862
* cosocket: review and merge aviramc's [patch](https://github.com/openresty/lua-nginx-module/pull/290) for adding the `bsdrecv` method.
863
863
* add new API function `ngx.resp.add_header` to emulate the standard `add_header` config directive.
864
-
*[ngx.re](#ngxrematch) API: use `false` instead of `nil` in the resulting match table to indicate non-existent submatch captures, such that we can avoid "holes" in the array table.
865
864
* review and apply Jader H. Silva's patch for `ngx.re.split()`.
866
865
* review and apply vadim-pavlov's patch for [ngx.location.capture](#ngxlocationcapture)'s `extra_headers` option
867
866
* use `ngx_hash_t` to optimize the built-in header look-up process for [ngx.req.set_header](#ngxreqset_header), [ngx.header.HEADER](#ngxheaderheader), and etc.
@@ -5524,16 +5523,16 @@ and are returned in the same Lua table as key-value pairs as the numbered captur
5524
5523
-- m["remaining"] == "234"
5525
5524
```
5526
5525
5527
-
Unmatched subpatterns will have `nil` values in their `captures` table fields.
5526
+
Unmatched subpatterns will have `false` values in their `captures` table fields.
Copy file name to clipboardExpand all lines: doc/HttpLuaModule.wiki
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -698,7 +698,6 @@ phases.
698
698
* cosocket: pool-based backend concurrency level control: implement automatic <code>connect</code> queueing when the backend concurrency exceeds its connection pool limit.
699
699
* cosocket: review and merge aviramc's [https://github.com/openresty/lua-nginx-module/pull/290 patch] for adding the <code>bsdrecv</code> method.
700
700
* add new API function <code>ngx.resp.add_header</code> to emulate the standard <code>add_header</code> config directive.
701
-
* [[#ngx.re.match|ngx.re]] API: use <code>false</code> instead of <code>nil</code> in the resulting match table to indicate non-existent submatch captures, such that we can avoid "holes" in the array table.
702
701
* review and apply Jader H. Silva's patch for <code>ngx.re.split()</code>.
703
702
* review and apply vadim-pavlov's patch for [[#ngx.location.capture|ngx.location.capture]]'s <code>extra_headers</code> option
704
703
* use <code>ngx_hash_t</code> to optimize the built-in header look-up process for [[#ngx.req.set_header|ngx.req.set_header]], [[#ngx.header.HEADER|ngx.header.HEADER]], and etc.
@@ -4593,15 +4592,15 @@ and are returned in the same Lua table as key-value pairs as the numbered captur
4593
4592
-- m["remaining"] == "234"
4594
4593
</geshi>
4595
4594
4596
-
Unmatched subpatterns will have <code>nil</code> values in their <code>captures</code> table fields.
4595
+
Unmatched subpatterns will have <code>false</code> values in their <code>captures</code> table fields.
4597
4596
4598
4597
<geshi lang="lua">
4599
4598
local m, err = ngx.re.match("hello, world", "(world)|(hello)|(?<named>howdy)")
4600
4599
-- m[0] == "hello"
4601
-
-- m[1] == nil
4600
+
-- m[1] == false
4602
4601
-- m[2] == "hello"
4603
-
-- m[3] == nil
4604
-
-- m["named"] == nil
4602
+
-- m[3] == false
4603
+
-- m["named"] == false
4605
4604
</geshi>
4606
4605
4607
4606
Specify <code>options</code> to control how the match operation will be performed. The following option characters are supported:
0 commit comments