作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下文字:
[FONT=arial, helvetica]this
is a multiline text
[/FONT]
[FONT=arial, helvetica] this is a single line comment[/FONT]
我正在尝试将 bbcode 标签内的文本与此模式匹配:
\[FONT=(.*?)\](.*?)\[\/FONT\]\im
但是它只匹配单行文本,为什么?我什至添加了多行标志。
最佳答案
这里需要单行,而不是多行标志。
/\[FONT=(.*?)\](.*?)\[\/FONT\]/isg
单行修饰符使点符号也匹配换行符 - 这正是您的问题。
多行修饰符仅使开始/结束字符(^
和 $
)匹配行的开始/结束。
关于php - 匹配多行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30847906/
我是一名优秀的程序员,十分优秀!