嘿伙计们你能帮我解决这个问题吗,一个正则表达式语法来做以下事情
- 如果链接以//开头,那么我将进行字符串连接以添加"文件:"
- 如果链接以任何内容开头,我将进行字符串连接以添加"html://"
示例 1(如果它以
host/data/user/temp/data.text 想要让它成为"file://host/data/user..."
示例:对于 2,如果它以
Google.com 我想让它"html://Google.com"
Try this.
$subject = 'filename';
//$subject = '//filename';
if(preg_match("/^'/'//", $subject)){
//$newstring= preg_replace("/^'/'//", "file://", $subject);
$newstring= "file:".$subject;
}else{
$newstring= "http://".$subject;
}