\xnn 匹配中ASCII代码十六进制代码为nn的字符。
[\x00-\x7F] 匹配ASCII值从0-127的字符。
0-127表示单字节字符,也就是:数字,英文字符,半角符号,以及某些控制字符。

 

正则示例:

<?php

$test_str = 'a'.chr(0).'bcdefj'.chr(0).'h';

//ASCII码中十进制 0 对应 十六进制 00
$hex_str = '\x00';

$pattern =  sprintf('/a%s[0-9a-zA-Z]{6}%sh/',$hex_str,$hex_str);

preg_match_all($pattern,$test_str,$output); 
var_dump($output);


$test_str = 'a'.chr(31).'bcdefj'.chr(31).'h';

//ASCII码中十进制 31 对应 十六进制 1F
$hex_str = '\x1F';

$pattern =  sprintf('/a%s[0-9a-zA-Z]{6}%sh/',$hex_str,$hex_str);

preg_match_all($pattern,$test_str,$output); 
var_dump($output);

 

相关文章:

  • 2021-10-30
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-07-05
  • 2021-10-10
  • 2021-08-28
相关资源
相似解决方案