Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
10php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu Kimiduka
10php
Commits
0652266e
Commit
0652266e
authored
Jul 11, 2016
by
君塚 悠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
プログラム作成(regex.php,data.bat:正規表現)
parent
aac957bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
data.dat
php/php10/day05-3/data.dat
+3
-0
regex.php
php/php10/day05-3/regex.php
+27
-0
No files found.
php/php10/day05-3/data.dat
0 → 100644
View file @
0652266e
*******************http://test.co.jp*********
htphtptphtppps://t***************************
http://aaaaaaa
\ No newline at end of file
php/php10/day05-3/regex.php
0 → 100644
View file @
0652266e
<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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment