函数原型

func (s1 string) bmatches(b1 bytes) bool

参数介绍

参数名称参数介绍
s1匹配语句
b1待匹配的内容

举例

  • Response

    HTTP/1.1 200 OK
    Server: nginx
    Date: Sat, 07 Jan 2023 10:41:06 GMT
    Content-Type: text/html; charset=utf-8
    Connection: close
    Vary: Accept-Encoding
    Cache-Control: no-cache
    Content-Length: 373
    
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
    bin:x:2:2:bin:/bin:/usr/sbin/nologin
    sys:x:3:3:sys:/dev:/usr/sbin/nologin
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/usr/sbin/nologin
    man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
    lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
    mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
    
  • 匹配语句:"root:.*?:[0-9]*:[0-9]*:".bmatches(response.body)

  • 输出结果:true

  • 匹配语句:"Accept-Enco.*".bmatches(response.raw)

  • 输出结果:true

Was this page helpful?