Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
やあみんな、これを手伝ってくれませんか、次のことを行うための正規表現構文です
1 の例//host/data/user/temp/data.textで始まる場合、 「file://host/data/user...」にしたい
例: for 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; }