Q:

Creating regular expression in php

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

A:

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 i.e. (\d{24})
Code Demo

