Commit 0652266e authored by 君塚 悠's avatar 君塚 悠

プログラム作成(regex.php,data.bat:正規表現)

parent aac957bc
*******************http://test.co.jp*********
htphtptphtppps://t***************************
http://aaaaaaa
\ No newline at end of file
<html>
<head>
<title>正規表現によるデータ検索</title>
</head>
<body>
<h1 style="background: #cccccc">正規表現によるデータ検索</h1>
<?php
if($file = fopen("data.dat", "r")) {
echo"ファイルあり";
} else {
echo "ファイルなし";
}
//開けたファイルから1行ずつ読み込み&正規表現による検索
while ($row = fgets($file, 1024)) {
//正規表現の節々にスペースは入れない
if(eregi('(http://|https://)[a-z0-9./_\-]+', $row, $data)) {
print($data[0]."<br />");
} else {
echo "発見できず";
}
}
fclose($file)
?>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment