Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegEx in Sublime Text: Match any character, including newlines?

Is there a way to match any character in Sublime Text, including newlines? I saw that Sublime uses Boost's syntax but that the . character won't match newlines without a specific flag set.

like image 498
Joseph Avatar asked Aug 16 '12 17:08

Joseph


People also ask

How do you match a character including newline in regex?

We want any number of characters that are not double quotes or newlines between the quotes. So the proper regex is "[^"\r\n]*". If your flavor supports the shorthand \v to match any line break character, then "[^"\v]*" is an even better solution.

What regex matches any character?

Matching a Single Character Using Regex By default, the '. ' dot character in a regular expression matches a single character without regard to what character it is. The matched character can be an alphabet, a number or, any special character.

What character in regex is used to match any character except a newline?

A metacharacter is a symbol with a special meaning inside a regex. The metacharacter dot ( . ) matches any single character except newline \n (same as [^\n] ).

How do I use regular expressions in Sublime Text?

To use regular expressions in Sublime Text, first activate them in the corresponding search panel by clicking on the available buttons or using keyboard shortcuts. If you don't activate regular expressions before performing a search, the search terms will be interpreted literally. Documentation on regular expressions.


1 Answers

Try adding the (?s) inline flag start the start of the pattern. That will make . match any character.

like image 108
MRAB Avatar answered Sep 18 '22 09:09

MRAB