Sublime Text regex 不检测多行标签 [英] Sublime Text regex not detecting multiline tags

查看:63
本文介绍了Sublime Text regex 不检测多行标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有这个正则表达式;

I have this regex here;

\[sometag\](.*)\[/sometag\]

应该捕获被 [sometag] 标签包围的文本.它适用于包含在这些标签中的单行信息,例如字符串 [sometag]this is a bit of text[/sometag].但它不适用于跨越多行的文本,就像这样;

Which is supposed to catch text surrounded by the [sometag] tag. It works for single line information contained in these tags, like on the string [sometag]this is a bit of text[/sometag]. But it doesn't work on text that spans multiple lines, like this;

[sometag] here is more text

it spans more than one line [/sometag]

出于某种原因,Sublime text 的正则表达式查找器无法识别多行的标签.我想知道这是 Sublime Text 的问题、可切换的选项,还是我个人对正则表达式的无能.

For some reason, Sublime text's regex finder won't recognize the tags across multiple lines. I want to know if this a problem with Sublime Text, a toggleable option, or just my personal incompetence with regexes.

推荐答案

在开始时,使用 dotall 修饰符 (?s) 使点匹配换行符.

At the start, use a dotall modifier (?s) to make dot to match also newline characters.

(?s)\[sometag\](.*?)\[\/sometag\]

演示

这篇关于Sublime Text regex 不检测多行标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆