0

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.

3 Answers 3

1

Not sure if i understood your expectation right, buf how about something like this:

^\s*<FooBar>\s*\((\n|.)*\)
2
  • Sorry, I need them all to be matched, single lines and multi lines. Commented Jul 12, 2012 at 12:57
  • The regex above matches single lines AND multi lines
    – Julien May
    Commented Jul 12, 2012 at 12:58
0

Notepad++ does not properly support regexes spanning multiple lines. I did find this workaround: https://stackoverflow.com/a/4473041/785745

0

If you are specifically looking for Notepad++ multiline regular expressions, look at this post.

Not the answer you're looking for? Browse other questions tagged or ask your own question.