My attempt
preg_match("/^logs.\d{24}.\d{24}.{4}$/", $input_line, $output_array);
If matched return \d{24} in echo
String
logs/532523532543353444444444/532523532543353444444444.log
Preg match peseudo-code : logs/{24 digitals}/{same24digits}.log
Both \\d{24}
are the same number
Question How to get the : If matched return \\d{24} in echo
You can use:
if (preg_match('~^logs/(\d{24})/\1\.log$~', $input_line, $m))
echo $m[1];
\\1
ia back-reference to first captured group ie (\\d{24})
logs\/(\d{24})\/\1.log
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.