Php regular matching backslash + digit exception, solve

I am modifying a WordPress plug-in that needs to be intercepted from the source code of the web page generated by WordPress. However, there are occasional cases of backslash + number in the source code, and the matching result is abnormal, and the backslash and the following two digits will be swallowed in the result.

<?php
header("Content-type: text/html; charset=UTF8");

//  demo "" 
$str="
<div class=\"post_t\">

\f
\1
\9999
<div></div>
</div>";
$regexp="/\"post_t\".*<div/s";
preg_match($regexp, $str ,$match);
echo $match[0];

// :
// \f  \f
// \1 
// \9999  99

I am puzzled. Even if the backslash is treated as some other base, it should not be swallowed. I do not know if you have encountered this situation, do you have any experience, thank you!

May.14,2021

is treated as an escape character: the combination of a backslash and a number indicates a reference to the previously matched capture group.
look at a regular example (\ d)\ 1 : it will match all two consecutive equal numbers, where \ 1 represents the same value as the first capture group \ d .
for the string ss22345 , it matches to 22. The number after the backslash is a reference to which capture group, and the rule generally can only get a maximum of 99 capture groups.
therefore, \ 1 and \ 99 in your string are resolved as capture group references, while the ninety-ninth capture group of the first capture combination does not exist at all. It is treated as null by default, which is what you call "swallowing"

.
Menu