关 键 词:
正则表达式例子:在一个字符串中查找另一个字符串
<head><title>正则表达式</title></head>
<body>
<a href="./">返回列表</a><br>
<form action="<?echo $PHP_SELF;?>" method="post">
在<input type="text" name="string" value="<?echo $string;?>">中查找<input type="text" name="query" value="<?echo $query;?>"><br>
<input type="radio" name="where" value="" <?if(!isset($where) or $where=="") echo "checked";?>>第二个字符串可以在第一个字符串的任何位置<br>
<input type="radio" name="where" value="^" <?if(isset($where) and $where=="^") echo "checked";?>>第一个字符串以第二个字符串开始<br>
<input type="radio" name="where" value="$" <?if(isset($where) and $where=="$") echo "checked";?>>第一个字符串以第二个字符串结束<br>
<input type="checkbox" name="case" value="case" <?if(isset($case)) echo "checked";?>>区分大小写<br>
<input type="submit" value="查询">
</form>
<?
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 "找到!";
}
else{
echo "未找到!";
}
}
?>
</body>
</html>欢迎进入PHP开发资源论坛讨论。
·Zope的优点及和Apache+PHP+MySQL的比较
·PHP面向对象、类经典教程[2]
·PHP面向对象、类经典教程[1]
·用 Xdebug 修正 PHP 应用程序中的错误(5)
·用 Xdebug 修正 PHP 应用程序中的错误(4)
·用 Xdebug 修正 PHP 应用程序中的错误(3)
·用 Xdebug 修正 PHP 应用程序中的错误(2)
·用 Xdebug 修正 PHP 应用程序中的错误(1)
·黑防黑:黑客口述—关于Php后门的隐藏技巧
·PRADO框架TDataGrid使用教程(1)
·PHP面向对象、类经典教程[2]
·PHP面向对象、类经典教程[1]
·用 Xdebug 修正 PHP 应用程序中的错误(5)
·用 Xdebug 修正 PHP 应用程序中的错误(4)
·用 Xdebug 修正 PHP 应用程序中的错误(3)
·用 Xdebug 修正 PHP 应用程序中的错误(2)
·用 Xdebug 修正 PHP 应用程序中的错误(1)
·黑防黑:黑客口述—关于Php后门的隐藏技巧
·PRADO框架TDataGrid使用教程(1)
热门技术文档
·Zope的优点及和Apache+PHP+MySQL的比较
·Windows 下的 PHP 扩展编程
·PHP面向对象、类经典教程[2]
·PHP面向对象、类经典教程[1]
·用 Xdebug 修正 PHP 应用程序中的错误(5)
·用 Xdebug 修正 PHP 应用程序中的错误(4)
·用 Xdebug 修正 PHP 应用程序中的错误(3)
·用 Xdebug 修正 PHP 应用程序中的错误(2)
·用 Xdebug 修正 PHP 应用程序中的错误(1)
·php时间求法(二)
·Windows 下的 PHP 扩展编程
·PHP面向对象、类经典教程[2]
·PHP面向对象、类经典教程[1]
·用 Xdebug 修正 PHP 应用程序中的错误(5)
·用 Xdebug 修正 PHP 应用程序中的错误(4)
·用 Xdebug 修正 PHP 应用程序中的错误(3)
·用 Xdebug 修正 PHP 应用程序中的错误(2)
·用 Xdebug 修正 PHP 应用程序中的错误(1)
·php时间求法(二)
最新图文档
本站编辑推荐:(本站开通Delphi4PHP专区,欢迎进入论坛交流!)
- · 3分钟快速了解 Delphi for PHP 特色 (中文), PDF档
- · 购买Delphi for PHP的五大理由, PDF档
- · Delphi for PHP 使用规格介绍, PDF档
- · Delphi for PHP 問答集 (From CodeGear)
- · Delphi for PHP 产品价格表
编缉最近更新文章
网站赞助商
搜索您感兴趣的内容




