fork(3) download
  1. <?php
  2.  
  3. $rest = "";
  4. $re = '~\b(https?://)www\.myweb\.com/(\S+\b)~';
  5. $str = "Some text https://w...content-available-to-author-only...b.com/page/cat/323123442321-rghe432, another http://w...content-available-to-author-only...b.com/page/cat/323123442321-rghe432 and then another https://w...content-available-to-author-only...e.com/fsdhjss/erwr";
  6. echo $result = preg_replace_callback($re, function ($m) use (&$rest) {
  7. $rest = $m[2];
  8. return $m[1] . "embed.myweb.com/" . $m[2];
  9. }, $str, 1) . PHP_EOL;
  10. echo $rest;
Success #stdin #stdout 0.03s 52432KB
stdin
Standard input is empty
stdout
Some text https://e...content-available-to-author-only...b.com/page/cat/323123442321-rghe432, another http://w...content-available-to-author-only...b.com/page/cat/323123442321-rghe432 and then another https://w...content-available-to-author-only...e.com/fsdhjss/erwr
page/cat/323123442321-rghe432