Sublime Text 正则表达式未检测到多行标签 [英] Sublime Text regex not detecting multiline tags

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

问题描述

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

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 文本的正则表达式查找器无法识别多行的标签.我想知道这是 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) 使 dot 也匹配换行符.

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

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

演示

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

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