m 是将字符串作为多行处理,s是将字符串作为单行处理,如果是s在字符串中出现的\n就相当于普通字符。

6.6. Matching Within Multiple Lines
6.6.1. Problem
You want to use regular expressions on a string containing more than one logical line, but the special characters . (any character but newline), ^ (start of string), and $ (end of string) don't seem to work for you. This might happen if you're reading in multiline records or the whole file at once.

6.6.2. Solution
Use /m, /s, or both as pattern modifiers. /s allows . to match a newline (normally it doesn't). If the target string has more than one line in it, /foo.*bar/s could match a "foo" on one line and a "bar" on a following line. This doesn't affect dots in character classes like [#%.], since they are literal periods anyway.

The /m modifier allows ^ and $ to match immediately before and after an embedded newline, respectively. /^=head[1-7]/m would match that pattern not just at the beginning of the record, but anywhere right after a newline as well.

perl学习之:匹配修饰符/s /m的更多相关文章

  1. Vue – 基础学习(4):事件修饰符

    Vue – 基础学习(3):事件修饰符

  2. php基础32:正则匹配-修饰符

    <?php //正则表达式--修饰符一般放在//的外面 //1. i 表示不区分大小写 $model = "/php/"; $string = "php" ...

  3. java学习(权限修饰符)

    Java中,可以使用访问控制符来保护对类.变量.方法和构造方法的访问.Java 支持 4 种不同的访问权限. default (即缺省,什么也不写): 在同一包内可见,不使用任何修饰符.使用对象:类. ...

  4. Vue.js学习笔记之修饰符详解

    本篇将简单介绍常用的修饰符. 在上一篇中,介绍了 v-model 和 v-on 简单用法.除了常规用法,这些指令也支持特殊方式绑定方法,以修饰符的方式实现.通常都是在指令后面用小数点“.”连接修饰符名 ...

  5. C#深入学习:泛型修饰符in,out、逆变委托类型和协变委托类型

    在C#中,存在两个泛型修饰符:in和out,他们分别对应逆变委托和协变委托. 我们知道,在C#中要想将一个泛型对象转换为另一个泛型对象时,必须要将一个泛型对象拆箱,对元素进行显式或隐式转换后重新装箱. ...

  6. vue学习(六) 事件修饰符 stop prevent capture self once

    //html <div id="app"> <div @click="divHandler" style="height:150px ...

  7. Java学习——使用final修饰符

    package Pack1; import java.awt.*; import java.applet.*; class ca { static int n = 20; final int nn; ...

  8. Java学习——使用Static修饰符

    程序功能:通过两个类 StaticDemo.LX4_1 说明静态变量/方法与实例变量/方法的区别. package Pack1; public class Try { public static vo ...

  9. 27.28. VUE学习之--事件修饰符之stop&capture&self&once实例详解

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

随机推荐

  1. iReport - 无法正常启动的解决方法

    问题与分析 最近需要用到iReport报表工具,但是在启动客户端时却发现只出现了启动界面,很快就界面消失没反应了.反复打开了好几次客户端,都无法正常打开.问了下同事,说是因为jdk升级的原因,以前项目 ...

  2. php7+新特性

    php7已经发布有段时间了,查了下正式版本的发布时间是2015年底,至于具体的新特性,在这里总结一下. 标量类型声明 php7新增了4种类型, 字符串(string), 整数 (int), 浮点数 ( ...

  3. python连接redis数据库的两种方式

    代码: # __author__ = 'STEVEN' import redis # 方式1,直接连接 # r = redis.Redis(host='192.168.43.22',port=6379 ...

  4. DRF教程5-API接口文档和接口测试

    配置 配置好,就可以访问web页面 pip install coreapi #安装依赖 from rest_framework.documentation import include_docs_ur ...

  5. HDU - 6312( 2018 Multi-University Training Contest 2)

    bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6312 输出前几项,都是"Yes" #include <bits ...

  6. Jasper_crosstab_headerPosition_columngroup header position config - (headerPosition="Stretch")

    i.e <columnGroup name="column11" height="20" totalPosition="Start" ...

  7. Hibernate、Spring和Struts工作原理及使用理由

    1.读取并解析配置文件2.读取并解析映射信息,创建SessionFactory3.打开Sesssion4.创建事务Transation5.持久化操作6.提交事务7.关闭Session8.关闭Sesst ...

  8. JS中函数与事件

    一.函数: 1.函数就是一个工具,通过一小段代码,完成某个功能: 2.函数的定义: function 函数名(){ ..... } 或者 : var 函数名 = function(){ ...... ...

  9. c语言中的->代表什么意思

    c语言中 ->符号是什么意思? 比如c=a->b a为结构体或联合体的指针,->表示调用其成员

  10. 浏览器对DIV+CSS兼容性问题大总结

    浏览器对DIV+CSS兼容性问题大总结 接触DIV+CSS架构已经快两年了,个人觉得css入门不难,但要学精并非一朝一夕的,现在大部分网络公司都比较主张用div+css来布局,这就面临着一个比较难的问 ...