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.

最新文章

  1. 常见的特殊字符和HTML之间的对应关系~
  2. nyoj 712 探 寻 宝 藏--最小费用最大流
  3. iOS - Swift 命令行输入输出
  4. nignx+php-fpm环境下 phpmyadmin打开空白的原因探究
  5. [020] Android模拟器访问本地Web应用
  6. Shell统计报表表格生成
  7. 配置servers时,错误:Setting property 'source' to 'org.eclipse.jst.jee.server:hczm' did not find a matching property
  8. System.Web.Http.Tracing 在webapi里面应用
  9. POJ 1065 Wooden Sticks / hdu 1257 最少拦截系统 DP 贪心
  10. python网络爬虫之LXML与HTMLParser
  11. spring实例化dataSource使用jndi和jdbc两种方式
  12. Anaconda的安装与使用
  13. 002_监测ssl证书过期时间
  14. 梯度下降取负梯度的简单证明,挺有意思的mark一下
  15. OpenStack 安装:keystone服务
  16. c# Datatable导出Excel
  17. POJ 3017 Cut the Sequence
  18. usaco 洛谷 P2694 接金币 题解
  19. ios中Pldatabase的用法
  20. POJ1179 Polygon

热门文章

  1. JAVA团队开发手册 - 3. 开发流程
  2. Turtles (非纯分块)
  3. 51nod 1562 玻璃切割 (set)
  4. ZOJ 4016 Mergeable Stack(from The 18th Zhejiang University Programming Contest Sponsored by TuSimple)
  5. dzzoffice 任意文件删除漏洞分析
  6. POJ1470 LCA (Targan离线)
  7. 安装linux时的分区问题,需要了解目录树及挂载知识
  8. REST访问(RestTemplate)
  9. 使用JOSM编辑OpenStreetMap地图
  10. SAP Cloud for Customer(C4C)的一些学习资料