Reputation: 1
I am using Regex in Notepad++ trying to match a general patten like below:
/*
<FooBar>(<--find open bracket and end on finding a closing bracket-->)
<FooBar> (foo
bar);
<FooBar> (foo
bar
baz)
*/
I am trying to match using:
^\s*?<FooBar>\s+?.+?\(.*?\)
with "matches newline" enabled but it's not working as intended; the bookmarked lines show above on blank lines and fail to bookmark all the lines I need.
I want to use this regex to search in multiple files for matches using the "find in files".
So I found some things out. Because it's using multi-line the \s* will match before it reaches foobar. So removing all back lines by replacing
^\s+
with nothing solves this problem.
^\s*<foobar>\s+.+?\(.*?\)
matches exactly what I need but with one problem and that's that notepad++ doesn't bookmark all marked lines, only the start of a find; if it's a multi-line find it will just bookmark the first line that matches (although the rest will be marked). So this means that if you search using "find in files" it will only return the bookmarked lines which is not so useful.
However, you can remove all unmarked lines by going Search-->Remove Unbookmarked Lines but I need to do a batch search so this seems to be out of the question.
However, other editors return all marked lines such as editpad pro.
Upvotes: 0
Views: 281
Reputation: 10367
If you are specifically looking for Notepad++ multiline regular expressions, look at this post.
Upvotes: 0
Reputation: 44316
Notepad++ does not properly support regexes spanning multiple lines. I did find this workaround: https://stackoverflow.com/a/4473041/785745
Upvotes: 0
Reputation: 2051
Not sure if i understood your expectation right, buf how about something like this:
^\s*<FooBar>\s*\((\n|.)*\)
Upvotes: 1