使用此preg_replace调用:
$str = 'File:MyFile.jpg';
$repl = preg_replace('/^[^:]*:/', '', $str); // MyFile.jpg
Run Code Online (Sandbox Code Playgroud)
或者避免正则表达式并使用像这样的爆炸:
$repl = explode(':', $str)[1]; // MyFile.jpg
Run Code Online (Sandbox Code Playgroud)
编辑:使用这种方式来避免正则表达式(如果可以有多个:在字符串中):
$arr = explode(':', 'File:MyFile.jpg:foo:bar');
unset($arr[0]);
$repl = implode(':', $arr); // MyFile.jpg:foo:bar
Run Code Online (Sandbox Code Playgroud)
编辑:这个效果很好。
$str = "File:MyFile.jpg";
$str = substr( $str, ( $pos = strpos( $str, ':' ) ) === false ? 0 : $pos + 1 );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6615 次 |
| 最近记录: |