zoukankan      html  css  js  c++  java
  • preg_match 函数

    preg_match 执行正则匹配表达式

    int preg_match (string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0]]])

    $partten 搜搜索的模式 字符串

    $subject 输入字符串

    $matches 若提供了参数 matches 它将被填充为搜索结果 $matches[0] 包含完整模式匹配到的文本$matches[1] 将包含第一个捕获子组匹配到的文本,以此类推。

    $flags 

    PREG_OFFSET_CAPTURE若传递此标记对于每一个出现的匹配会附加字符串偏移量

    $offset 从指定位置开始搜索

    返回值 返回 pattern 匹配的次数 0 或 1 在第一次匹配后会停止搜索 i 不区分大小写

    <?php

      if(preg_match("/php/i"), "php is the web scripting language of choice.")){

        echo "查找到匹配字符串 php";

      }else{

        echo "未发现匹配的字符串 php";

      };  

  • 相关阅读:
    IntelliJ Idea 快捷键列表
    mysql索引类型和方式
    基本git指令
    idea中deBug方法
    BeanUtils.copyProperties(A,B)使用注意事项
    MySQL字段类型
    JAVA常识1
    Redis在windows下的安装下载
    Netty
    IDEA工具
  • 原文地址:https://www.cnblogs.com/hiraeth/p/8588521.html
Copyright © 2011-2022 走看看