Sublime Text regex not detecting multiline tags

RegexTagsSublimetext

Regex Problem Overview


I have this regex here;

\[sometag\](.*)\[/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]

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.

Regex Solutions


Solution 1 - Regex

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

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

DEMO

Solution 2 - Regex

If modifying of dot's mode is inadmissible for some reasons, you may take that:

[sometag](.|\n)+?[/sometag]

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaurdekyeView Question on Stackoverflow
Solution 1 - RegexAvinash RajView Answer on Stackoverflow
Solution 2 - RegexSynCapView Answer on Stackoverflow