<?php
$str = 'php is the best language phhhhp is';
$part = '/ph{1,}p/';
echo preg_match($part, $str,$ar1);
var_dump($ar1);
echo preg_match_all($part, $str,$ar);
var_dump($ar);
echo $ar[0][0];
1
array
0 => string 'php' (length=3)
2
array
0 =>
array
0 => string 'php' (length=3)
1 => string 'phhhhp' (length=6)
php

php比较两个数组不同元素 函数array_diff:

常用函数:

$a = array('a','b','c');
$b = array('a','b','d');
$c = array_diff($a,$b);

$d = array_diff($b,$a);

打印:

$c = array('c');

$d = array('d');

php正则表达式:

http://deerchao.net/tutorials/regex/regex-1.htm

需要转义字符:

\  .  *  ^  &  [  ]  {  }  ?

php 函数preg_match、preg_match_all ,以及正则表达式规则的更多相关文章

  1. RegExp正则表达式规则以及常用正则表达式

    html,body { font-family: "SF UI Display", ".PingFang SC", "PingFang SC" ...

  2. PHP 正则表达式匹配函数 preg_match 与 preg_match_all

    preg_match() preg_match() 函数用于进行正则表达式匹配,成功返回 1 ,否则返回 0 . 语法: 1 int preg_match( string pattern, strin ...

  3. php中函数preg_match或preg_match_all 第三个参数$match的解释

    理解自:http://www.cnblogs.com/vicenteforever/articles/1623137.html php手册中是这样解释的 matches 如果提供了参数matches, ...

  4. 正则表达式,匹配查找函数(preg_match_all)flags参数对比

    格式: int preg_match_all ( string pattern, string subject, array matches [, int flags] ) 参数 flags 选项有以 ...

  5. PHP函数preg_match()

    部分内容来自:http://www.nowamagic.net/librarys/veda/detail/1054 preg_match — 进行正则表达式匹配. 语法:int preg_match ...

  6. Python开发【内置函数篇】re正则表达式

    一.简介 正则表达式本身是一种小型的.高度专业化的编程语言,而在python中,通过内嵌集成re模块,程序媛们可以直接调用来实现正则匹配.正则表达式模式被编译成一系列的字节码,然后由用C编写的匹配引擎 ...

  7. Python 正则表达式规则

    正则表达式的一些匹配规则: . :用于匹配任意一个字符,如 a.c 可以匹配 abc .aac .akc 等^ :用于匹配以...开头的字符,如 ^abc 可以匹配 abcde .abcc .abca ...

  8. 学习PHP函数:preg_match_all

    <?php $str = '10.10.10.10, 10.10.10.11'; preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', ...

  9. WebMisSharp,WebMisCentral,企业框架正则表达式规则共享专版

    ElegantWM.WebUI/Application/common/src/Tools.js 欢迎大家贡献更多的正则验证规则,目前支持如下: /*************************** ...

随机推荐

  1. Deep Learning 9_深度学习UFLDL教程:linear decoder_exercise(斯坦福大学深度学习教程)

    前言 实验内容:Exercise:Learning color features with Sparse Autoencoders.即:利用线性解码器,从100000张8*8的RGB图像块中提取颜色特 ...

  2. C++ Primer 第九章 顺序容器

    由于书籍上写的已经很经典了,故大部分用图片的形式来阐述概念,代码纯手打进行验证. 1.顺序容器类型:vector.deque.list.forword_list.array.string. 2.顺序容 ...

  3. PBcR - 纠错及组装算法

    单分子测序reads(PB)的混合纠错和denovo组装 我们广泛使用的PBcR的原始文章就是这一篇 原文链接:Hybrid error correction and de novo assembly ...

  4. 用OPencv配置vs2010

    第一次作业,图像的识别存储和显示 此次选用的是Microsoft Visual Studio 2010软件,在配置和opencv的时候,要选好版本苟泽造成不兼容,因此我选用的为opencv 2.4.1 ...

  5. 简单研究Android View绘制二 LayoutParams

    2015-07-28 17:23:20 本篇是关于LayoutParams相关 ViewGroup.LayoutParams文档解释如下: LayoutParams are used by views ...

  6. 将从数组中取到的字符串赋值给了UIImage导致的错误

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantStr ...

  7. mysql插入数据后返回自增ID的方法

    mysql和oracle插入的时候有一个很大的区别是,oracle支持序列做id,mysql本身有一个列可以做自增长字段,mysql在插入一条数据后,如何能获得到这个自增id的值呢? 方法一是使用la ...

  8. hessionproxy

    from pyhessian.client import HessianProxy if __name__ == '__main__': params = {"a": " ...

  9. 解决如何监听Activity切换

    本篇博文在我之前的博文中已经提到了,但是监听Activity切换又可以作为一个单独的内容来叙述,因此这里又单独拿了出来进行赘述. Activity的切换无非有两种,第一种:启动或者创建一个新的Acti ...

  10. VC++ 文件系统

    using namespace System; using namespace System::IO; void ShowHelpMsg(){ Console::WriteLine(L"本程 ...