language: PHP (php 5.4.4)
date: 650 days 22 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
<?php
 
function replacer($matches) {
    $subject = preg_replace('/\?+/', '%s', $matches[0]);
    return vsprintf($subject, array(1, 2, 34));
}
 
$subject = "Replace ? question mark in brackets [? with ? incremental ??]? digits";
echo preg_replace_callback('/\[[^\]]*\]/', 'replacer', $subject);