Reputation: 9151
I need to replace the following pattern across multiple files.
this\.dialogs = {.*};
This works fine when I set the single line
flag here:
https://regex101.com/r/dF2yG3/2
However I can't get this to work in an editor like VS or Notepad++, it will only match a single line.
How do I change the regex or set flags in any of these editors so I can make it span multiple lines?
Upvotes: 4
Views: 456
Reputation: 626926
Note you would only want to use
(?s)this\.dialogs = \{.*\};
if you want to match a string from this.dialogs = {
up to the last }
.
To only match up to the closest };
, use
(?s)this\.dialogs = \{.*?\};
The (?s)
inline modifier forces a dot to match any character inlcuding a newline.
In Notepad++, you can use .
matches newline in Notepad++ option in the Find and Replace dialog instead of (?s)
.
In Visual Studio 2015 (and in VS2012, VS2013, too), you need to use
this\.dialogs = {[\s\S\r]*?};
to match a string from this.dialogs = {
up to the closest };
Upvotes: 4
Reputation: 4953
Escape the brackets and activate . matches newline
In notepad:
this\.dialogs = \{.*\};
Or better use
this\.dialogs = \{[^}]*\};
Upvotes: 0