Home > Backend Development > PHP Tutorial > Regular Expression Example: Find a String in Another String_PHP Tutorial

Regular Expression Example: Find a String in Another String_PHP Tutorial

WBOY
Release: 2016-07-13 17:21:26
Original
1116 people have browsed it



Regular expression


return list


in Search

>The second string can be anywhere in the first string

>The first string starts with the second string

< input type="radio" name="where" value="$" >The first string End with the second string

Case sensitive



if(isset($ string) and isset($query) and $string<>"" and $query<>""){
if(isset($case)){
$func = "ereg";
}
else{
$func = "eregi";
}
switch($where){
case "^":
$query = "^" . $query ;
break;
case "$":
$query .= "$";
break;
}
eval("$found = $func("$query" ,"$string");");
if($found){
echo "Found! ";
}
else{
echo "Not found! ";
}
}
?>




www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532484.htmlTechArticlehtml headtitle regular expression/title/head body a href="./"return list/abr form action= "?echo $PHP_SELF;?" method="post" Search in input type="text" name="string" value="?echo $string;?"...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template