fork download
  1. <?php
  2.  
  3. $x='xffx etgxrtgy hyh[pageid:2] t пепкеп пе
  4. [pageid:100|a]]
  5. exffxergtg rtg' ;
  6.  
  7. echo preg_replace_callback('/\[pageid:(\d+)(?:\|(\w+))?\]/',function($matches){
  8. return "{found:{$matches[1]} {$matches[2]} }";
  9. },$x);
Success #stdin #stdout #stderr 0.02s 52472KB
stdin
Standard input is empty
stdout
xffx etgxrtgy hyh{found:2  } t пепкеп пе
{found:100 a }]
exffxergtg rtg
stderr
PHP Notice:  Undefined offset: 2 in /home/KMSqeQ/prog.php on line 8