response_body_like

使用 Perl 正则表达式匹配响应体。

语法

--- response_body_like 使用 Perl 兼容正则表达式(PCRE)对响应体进行匹配。只要部分匹配即认为通过。

perl
1=== TEST 1: regex match
2--- config
3 location /t {
4 content_by_lua_block {
5 ngx.say("request id: " .. math.random(1000))
6 }
7 }
8--- request
9GET /t
10--- response_body_like
11^request id: \d+$