如何用php替换字符串


How Replace string with php

我需要替换这种字符串:

https://r2---sn-vgqs7nez.c.docs.google.com/
https://r2---sn-testne4.c.docs.google.com/
https://r5---sn-vfghtgh.c.docs.google.com/

到这个

https://redirector.googlevideo.com/

使用php,请帮助我

您可以使用此正则表达式来搜索和替换

$pattern = '/^(https:'/'/)[a-zA-Z0-9'-.]+.docs.google.com'//g';
preg_replace($pattern, 'https://redirector.googlevideo.com/', $yourstring);

证明:http://regexr.com/3d71p