• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

正则表达式例子:在一个字符串中查找另_php

php 搞代码 7年前 (2018-06-19) 134次浏览 已收录 0个评论

<html>
<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>

http://www.gaodaima.com/45272.html正则表达式例子:在一个字符串中查找另_php

<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,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:正则表达式例子:在一个字符串中查找另_php
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址